Commit 0b3ae4b1 authored by romanb's avatar romanb

[2.0] Removed all remaining references to deprecated allowPartialObjects option.

parent 9200e17b
......@@ -59,34 +59,6 @@ class Configuration extends \Doctrine\DBAL\Configuration
$this->_attributes['metadataDriverImpl'] = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
}
/**
* Gets a boolean flag that indicates whether partial objects are allowed.
*
* If partial objects are allowed, Doctrine will never use proxies or lazy loading
* and you always only get what you explicitly query for.
*
* @return boolean Whether partial objects are allowed.
* @todo Remove
* @deprecated
*/
public function getAllowPartialObjects()
{
return true;
}
/**
* Sets a boolean flag that specifies whether partial objects are allowed.
*
* If partial objects are allowed, Doctrine will never use proxies or lazy loading
* and you always only get what you explicitly query for.
*
* @param boolean $allowed Whether partial objects are allowed.
* @todo Remove
* @deprecated
*/
public function setAllowPartialObjects($allowed)
{}
/**
* Sets the directory where Doctrine generates any necessary proxy class files.
*
......
......@@ -237,18 +237,15 @@ class ObjectHydrator extends AbstractHydrator
private function _getEntityFromIdentityMap($className, array $data)
{
$class = $this->_ce[$className];
if ($class->isIdentifierComposite) {
$idHash = '';
foreach ($class->identifier as $fieldName) {
$idHash .= $data[$fieldName] . ' ';
}
$idHash = rtrim($idHash);
return $this->_uow->tryGetByIdHash(rtrim($idHash), $class->rootEntityName);
} else {
$idHash = $data[$class->identifier[0]];
return $this->_uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName);
}
return $this->_uow->tryGetByIdHash($idHash, $class->rootEntityName);
}
/**
......
......@@ -82,14 +82,6 @@ abstract class AssociationMapping
*/
public $isOwningSide = true;
/**
* Whether the association is optional (0..X) or not (1..X).
* By default all associations are optional.
*
* @var boolean
*/
public $isOptional = true;
/**
* The name of the source Entity (the Entity that defines this mapping).
*
......@@ -180,8 +172,6 @@ abstract class AssociationMapping
}
// Optional attributes for both sides
$this->isOptional = isset($mapping['optional']) ?
(bool)$mapping['optional'] : true;
$this->fetchMode = isset($mapping['fetch']) ?
$mapping['fetch'] : self::FETCH_LAZY;
$this->cascades = isset($mapping['cascade']) ?
......@@ -288,17 +278,6 @@ abstract class AssociationMapping
return ! $this->isOwningSide;
}
/**
* Whether the association is optional (0..X), or not (1..X).
*
* @return boolean TRUE if the association is optional, FALSE otherwise.
* @todo Only applicable to OneToOne. Move there.
*/
public function isOptional()
{
return $this->isOptional;
}
/**
* Gets the name of the source entity class.
*
......
......@@ -60,6 +60,14 @@ class OneToOneMapping extends AssociationMapping
*/
public $orphanRemoval = false;
/**
* Whether the association is optional (0..1) or not (1..1).
* By default all associations are optional.
*
* @var boolean
*/
public $isOptional = true;
/**
* The join column definitions.
*
......@@ -117,6 +125,8 @@ class OneToOneMapping extends AssociationMapping
$this->targetToSourceKeyColumns = array_flip($this->sourceToTargetKeyColumns);
}
$this->isOptional = isset($mapping['optional']) ?
(bool)$mapping['optional'] : true;
$this->orphanRemoval = isset($mapping['orphanRemoval']) ?
(bool) $mapping['orphanRemoval'] : false;
......@@ -127,6 +137,17 @@ class OneToOneMapping extends AssociationMapping
return $mapping;
}
/**
* Whether the association is optional (0..1), or not (1..1).
*
* @return boolean TRUE if the association is optional, FALSE otherwise.
* @todo Only applicable to OneToOne. Move there.
*/
public function isOptional()
{
return $this->isOptional;
}
/**
* Gets the join column definitions for this mapping.
*
......
......@@ -417,6 +417,13 @@ class StandardEntityPersister
public function load(array $criteria, $entity = null, $assoc = null)
{
$stmt = $this->_conn->prepare($this->_getSelectEntitiesSql($criteria, $assoc));
if (!is_object($stmt)) {
try {
throw new \Exception;
} catch (\Exception $e) {
var_dump($e->getTraceAsString());
}
}
$stmt->execute(array_values($criteria));
$result = $stmt->fetch(Connection::FETCH_ASSOC);
$stmt->closeCursor();
......
......@@ -1640,19 +1640,9 @@ class UnitOfWork implements PropertyChangedListener
public function isCollectionScheduledForDeletion(PersistentCollection $coll)
{
//...
return in_array($coll, $this->_collectionsDeletions, true);
}
/*public function scheduleCollectionRecreation(PersistentCollection $coll)
{
$this->_collectionRecreations[] = $coll;
}*/
/*public function isCollectionScheduledForRecreation(PersistentCollection $coll)
{
//...
}*/
/**
* INTERNAL:
* Creates an entity. Used for reconstitution of entities during hydration.
......
......@@ -43,7 +43,6 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$query = $this->_em->createQuery("select p from Doctrine\Tests\Models\Company\CompanyPerson p order by p.id asc");
$entities = $query->getResult();
......@@ -56,7 +55,6 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals('Roman S. Borschel', $entities[0]->getName());
$this->assertEquals('Guilherme Blanco', $entities[1]->getName());
$this->assertEquals(100000, $entities[1]->getSalary());
$this->_em->getConfiguration()->setAllowPartialObjects(true);
$this->_em->clear();
......@@ -197,8 +195,6 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$orgId = $org->getId();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyOrganization a where a.id = ?1');
$q->setParameter(1, $orgId);
......@@ -219,7 +215,5 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertTrue($events[0] instanceof CompanyRaffle);
$this->assertTrue($events[1] instanceof CompanyAuction);
}
$this->_em->getConfiguration()->setAllowPartialObjects(true);
}
}
......@@ -85,7 +85,6 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
{
$this->_createLoadingFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCategory');
$metadata->getAssociationMapping('products')->fetchMode = AssociationMapping::FETCH_LAZY;
......@@ -98,7 +97,6 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
{
$this->_createLoadingFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
$metadata->getAssociationMapping('categories')->fetchMode = AssociationMapping::FETCH_LAZY;
......
......@@ -73,7 +73,6 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
{
$this->_createLoadingFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
$metadata->getAssociationMapping('related')->fetchMode = AssociationMapping::FETCH_LAZY;
......
......@@ -78,7 +78,6 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
public function testLazyLoadsCollection()
{
$this->_createFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart');
$metadata->getAssociationMapping('products')->fetchMode = AssociationMapping::FETCH_LAZY;
......
......@@ -89,7 +89,6 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
public function testLazyLoadsOneToManyAssociation()
{
$this->_createFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCategory');
$metadata->getAssociationMapping('children')->fetchMode = AssociationMapping::FETCH_LAZY;
......
......@@ -67,7 +67,6 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testLazyLoadsObjectsOnTheOwningSide() {
$this->_createFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart');
$metadata->getAssociationMapping('customer')->fetchMode = AssociationMapping::FETCH_LAZY;
......@@ -82,7 +81,6 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testLazyLoadsObjectsOnTheInverseSide()
{
$this->_createFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer');
$metadata->getAssociationMapping('mentor')->fetchMode = AssociationMapping::FETCH_EAGER;
......@@ -98,8 +96,6 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testUpdateWithProxyObject()
{
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$cust = new ECommerceCustomer;
$cust->setName('Roman');
$cart = new ECommerceCart;
......@@ -131,8 +127,6 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$this->assertTrue($cart3->getCustomer() instanceof ECommerceCustomer);
$this->assertEquals('Roman', $cart3->getCustomer()->getName());
$this->_em->getConfiguration()->setAllowPartialObjects(true);
}
protected function _createFixture()
......
......@@ -66,7 +66,6 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
{
$this->_createFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer');
$metadata->getAssociationMapping('mentor')->fetchMode = AssociationMapping::FETCH_LAZY;
......
......@@ -61,7 +61,6 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testLazyLoadsObjects() {
$this->_createFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
$metadata->getAssociationMapping('shipping')->fetchMode = AssociationMapping::FETCH_LAZY;
......
......@@ -25,8 +25,6 @@ class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testAcceptsForeignKeysAsCriteria()
{
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$customer = new ECommerceCustomer();
$customer->setName('John Doe');
$cart = new ECommerceCart();
......
......@@ -132,7 +132,6 @@ class ObjectHydratorTest extends HydrationTestCase
$this->_em->setProxyFactory($proxyFactory);
// configuring lazy loading
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
$metadata->getAssociationMapping('shipping')->fetchMode = AssociationMapping::FETCH_LAZY;
......
......@@ -303,7 +303,6 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
// "Get all persons who have $person as a friend."
// Tough one: Many-many self-referencing ("friends") with class table inheritance
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$q3 = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends');
$person = new \Doctrine\Tests\Models\Company\CompanyPerson;
$this->_em->getClassMetadata(get_class($person))->setIdentifierValues($person, 101);
......@@ -312,7 +311,6 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
'SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c2_.salary AS salary3, c2_.department AS department4, c0_.discr AS discr5, c0_.spouse_id AS spouse_id6 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ INNER JOIN company_persons c4_ ON c3_.person_id = c0_.id WHERE c3_.friend_id = c4_.id AND c4_.id = ?)',
$q3->getSql()
);
$this->_em->getConfiguration()->setAllowPartialObjects(true);
}
public function testSupportsCurrentDateFunction()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment