1
0
Fork 0
mirror of synced 2025-04-01 12:26:11 +03:00

MultiGetCollectionHydrator depends knows the multi-get region

This commit is contained in:
Asmir Mustafic 2015-01-17 10:27:04 +01:00 committed by Marco Pivetta
parent 1bfa68d94f
commit 5ec2014051
2 changed files with 9 additions and 5 deletions

View file

@ -189,7 +189,7 @@ class DefaultCacheFactory implements CacheFactory
$targetRegion = $targetPersister->getCacheRegion();
if ($targetRegion instanceof MultiGetRegion) {
return new MultiGetCollectionHydrator($em);
return new MultiGetCollectionHydrator($em, $targetRegion);
}
}
}

View file

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