From 5ec201405143ce7adfe790a16d5fd3b574c20024 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 17 Jan 2015 10:27:04 +0100 Subject: [PATCH] MultiGetCollectionHydrator depends knows the multi-get region --- lib/Doctrine/ORM/Cache/DefaultCacheFactory.php | 2 +- .../ORM/Cache/MultiGetCollectionHydrator.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 1c322ce8d..04baf0de0 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -189,7 +189,7 @@ class DefaultCacheFactory implements CacheFactory $targetRegion = $targetPersister->getCacheRegion(); if ($targetRegion instanceof MultiGetRegion) { - return new MultiGetCollectionHydrator($em); + return new MultiGetCollectionHydrator($em, $targetRegion); } } } diff --git a/lib/Doctrine/ORM/Cache/MultiGetCollectionHydrator.php b/lib/Doctrine/ORM/Cache/MultiGetCollectionHydrator.php index dbf5c20dc..8770a48e2 100644 --- a/lib/Doctrine/ORM/Cache/MultiGetCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/MultiGetCollectionHydrator.php @@ -44,6 +44,11 @@ class MultiGetCollectionHydrator implements CollectionHydrator */ private $uow; + /** + * @var MultiGetRegion + */ + private $targetRegion; + /** * @var array */ @@ -52,10 +57,11 @@ class MultiGetCollectionHydrator implements CollectionHydrator /** * @param \Doctrine\ORM\EntityManagerInterface $em The entity manager. */ - public function __construct(EntityManagerInterface $em) + public function __construct(EntityManagerInterface $em, MultiGetRegion $targetRegion) { $this->em = $em; $this->uow = $em->getUnitOfWork(); + $this->targetRegion = $targetRegion; } /** @@ -78,8 +84,6 @@ class MultiGetCollectionHydrator implements CollectionHydrator public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection) { $assoc = $metadata->associationMappings[$key->association]; - $targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']); - $targetRegion = $targetPersister->getCacheRegion(); $list = array(); $keys = array(); @@ -87,7 +91,7 @@ class MultiGetCollectionHydrator implements CollectionHydrator $keys[$index] = new EntityCacheKey($assoc['targetEntity'], $identifier); } - $entityEntries = $targetRegion->getMulti($keys); + $entityEntries = $this->targetRegion->getMulti($keys); if ($entityEntries === null) { return null;