1
0
mirror of synced 2025-01-18 22:41:43 +03:00

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

This commit is contained in:
romanb 2009-10-15 19:03:27 +00:00
parent 9200e17bc1
commit 0b3ae4b169
17 changed files with 35 additions and 93 deletions

View File

@ -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.
*

View File

@ -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);
}
/**

View File

@ -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.
*

View File

@ -59,6 +59,14 @@ class OneToOneMapping extends AssociationMapping
* @var boolean
*/
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.
@ -78,7 +86,7 @@ class OneToOneMapping extends AssociationMapping
/**
* Creates a new OneToOneMapping.
*
* @param array $mapping The mapping info.
* @param array $mapping The mapping info.
*/
public function __construct(array $mapping)
{
@ -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;
@ -126,6 +136,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.

View File

@ -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();

View File

@ -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.

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
@ -97,9 +95,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
}
public function testUpdateWithProxyObject()
{
$this->_em->getConfiguration()->setAllowPartialObjects(false);
{
$cust = new ECommerceCustomer;
$cust->setName('Roman');
$cart = new ECommerceCart;
@ -130,9 +126,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$cart3 = $query2->getSingleResult();
$this->assertTrue($cart3->getCustomer() instanceof ECommerceCustomer);
$this->assertEquals('Roman', $cart3->getCustomer()->getName());
$this->_em->getConfiguration()->setAllowPartialObjects(true);
$this->assertEquals('Roman', $cart3->getCustomer()->getName());
}
protected function _createFixture()

View File

@ -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;

View File

@ -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;

View File

@ -24,9 +24,7 @@ class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase
}
public function testAcceptsForeignKeysAsCriteria()
{
$this->_em->getConfiguration()->setAllowPartialObjects(false);
{
$customer = new ECommerceCustomer();
$customer->setName('John Doe');
$cart = new ECommerceCart();

View File

@ -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;

View File

@ -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()