From 97ea6a7d85ceb2695dc02bd0e2d102215e851f41 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 24 Jan 2015 14:38:58 +0100 Subject: [PATCH] #1277 DDC-3346 - removing array-based persister context handling (better to just use private props) --- .../Entity/BasicEntityPersister.php | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index a1ad364e0..c16d31011 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -178,14 +178,19 @@ class BasicEntityPersister implements EntityPersister private $identifierFlattener; /** - * @var CachedPersisterContext[] + * @var CachedPersisterContext */ - protected $cachedPersisterContexts = []; + protected $currentPersisterContext; /** * @var CachedPersisterContext */ - protected $currentPersisterContext; + private $limitsHandlingContext; + + /** + * @var CachedPersisterContext + */ + private $noLimitsContext; /** * Initializes a new BasicEntityPersister that uses the given EntityManager @@ -196,18 +201,18 @@ class BasicEntityPersister implements EntityPersister */ public function __construct(EntityManagerInterface $em, ClassMetadata $class) { - $this->em = $em; - $this->class = $class; - $this->conn = $em->getConnection(); - $this->platform = $this->conn->getDatabasePlatform(); - $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); - $this->identifierFlattener = new IdentifierFlattener($em->getUnitOfWork(), $em->getMetadataFactory()); - $this->cachedPersisterContexts['noLimits'] = $this->currentPersisterContext = new CachedPersisterContext( + $this->em = $em; + $this->class = $class; + $this->conn = $em->getConnection(); + $this->platform = $this->conn->getDatabasePlatform(); + $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); + $this->identifierFlattener = new IdentifierFlattener($em->getUnitOfWork(), $em->getMetadataFactory()); + $this->noLimitsContext = $this->currentPersisterContext = new CachedPersisterContext( $class, new Query\ResultSetMapping(), false ); - $this->cachedPersisterContexts['withLimits'] = new CachedPersisterContext( + $this->limitsHandlingContext = new CachedPersisterContext( $class, new Query\ResultSetMapping(), true @@ -1966,11 +1971,11 @@ class BasicEntityPersister implements EntityPersister protected function switchPersisterContext($offset, $limit) { if (null === $offset && null === $limit) { - $this->currentPersisterContext = $this->cachedPersisterContexts['noLimits']; + $this->currentPersisterContext = $this->noLimitsContext; return; } - $this->currentPersisterContext = $this->cachedPersisterContexts['withLimits']; + $this->currentPersisterContext = $this->limitsHandlingContext; } }