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

#1277 DDC-3346 DDC-3531 - caching the currently in use persister context

This commit is contained in:
Marco Pivetta 2015-01-22 18:15:10 +01:00
parent ebdfab8f2c
commit 8b9171c8ad

View File

@ -182,6 +182,11 @@ class BasicEntityPersister implements EntityPersister
*/
protected $cachedPersisterContexts = [];
/**
* @var CachedPersisterContext
*/
protected $currentPersisterContext;
/**
* Initializes a new <tt>BasicEntityPersister</tt> that uses the given EntityManager
* and persists instances of the class described by the given ClassMetadata descriptor.
@ -197,7 +202,11 @@ class BasicEntityPersister implements EntityPersister
$this->platform = $this->conn->getDatabasePlatform();
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
$this->identifierFlattener = new IdentifierFlattener($em->getUnitOfWork(), $em->getMetadataFactory());
$this->cachedPersisterContexts['noLimits'] = new CachedPersisterContext(
$this->cachedPersisterContexts['noLimits'] = $this->currentPersisterContext = new CachedPersisterContext(
$class,
new Query\ResultSetMapping()
);
$this->cachedPersisterContexts['withLimits'] = new CachedPersisterContext(
$class,
new Query\ResultSetMapping()
);
@ -1927,4 +1936,13 @@ class BasicEntityPersister implements EntityPersister
$sql = implode(' AND ', $filterClauses);
return $sql ? "(" . $sql . ")" : ""; // Wrap again to avoid "X or Y and FilterConditionSQL"
}
private function loadPersisterContext($offset, $limit)
{
if (null === $offset && null === $limit) {
$this->currentPersisterContext = $this->cachedPersisterContexts['noLimits'];
}
$this->currentPersisterContext = $this->cachedPersisterContexts['withLimits'];
}
}