MultiGetCollectionHydrator depends knows the multi-get region
This commit is contained in:
parent
1bfa68d94f
commit
5ec2014051
2 changed files with 9 additions and 5 deletions
|
@ -189,7 +189,7 @@ class DefaultCacheFactory implements CacheFactory
|
|||
$targetRegion = $targetPersister->getCacheRegion();
|
||||
|
||||
if ($targetRegion instanceof MultiGetRegion) {
|
||||
return new MultiGetCollectionHydrator($em);
|
||||
return new MultiGetCollectionHydrator($em, $targetRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue