Added constant
This commit is contained in:
parent
057e86eb27
commit
e561f47cb2
@ -19,6 +19,7 @@
|
||||
|
||||
namespace Doctrine\ORM\Internal\Hydration;
|
||||
|
||||
use Doctrine\ORM\UnitOfWork;
|
||||
use PDO;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
@ -94,8 +95,8 @@ class ObjectHydrator extends AbstractHydrator
|
||||
|
||||
$this->resultCounter = 0;
|
||||
|
||||
if ( ! isset($this->_hints['deferEagerLoad'])) {
|
||||
$this->_hints['deferEagerLoad'] = true;
|
||||
if ( ! isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) {
|
||||
$this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true;
|
||||
}
|
||||
|
||||
foreach ($this->_rsm->aliasMap as $dqlAlias => $className) {
|
||||
@ -152,7 +153,7 @@ class ObjectHydrator extends AbstractHydrator
|
||||
*/
|
||||
protected function cleanup()
|
||||
{
|
||||
$eagerLoad = (isset($this->_hints['deferEagerLoad'])) && $this->_hints['deferEagerLoad'] == true;
|
||||
$eagerLoad = (isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) && $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] == true;
|
||||
|
||||
parent::cleanup();
|
||||
|
||||
|
@ -851,7 +851,7 @@ class BasicEntityPersister
|
||||
$stmt = $this->conn->executeQuery($query, $params, $types);
|
||||
$hydrator = $this->em->newHydrator(($this->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT);
|
||||
|
||||
return $hydrator->hydrateAll($stmt, $this->rsm, array('deferEagerLoad' => true));
|
||||
return $hydrator->hydrateAll($stmt, $this->rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -908,7 +908,7 @@ class BasicEntityPersister
|
||||
|
||||
$hydrator = $this->em->newHydrator(($this->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT);
|
||||
|
||||
return $hydrator->hydrateAll($stmt, $this->rsm, array('deferEagerLoad' => true));
|
||||
return $hydrator->hydrateAll($stmt, $this->rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -939,7 +939,7 @@ class BasicEntityPersister
|
||||
private function loadArrayFromStatement($assoc, $stmt)
|
||||
{
|
||||
$rsm = $this->rsm;
|
||||
$hints = array('deferEagerLoad' => true);
|
||||
$hints = array(UnitOfWork::HINT_DEFEREAGERLOAD => true);
|
||||
|
||||
if (isset($assoc['indexBy'])) {
|
||||
$rsm = clone ($this->rsm); // this is necessary because the "default rsm" should be changed.
|
||||
@ -962,8 +962,8 @@ class BasicEntityPersister
|
||||
{
|
||||
$rsm = $this->rsm;
|
||||
$hints = array(
|
||||
'deferEagerLoad' => true,
|
||||
'collection' => $coll
|
||||
UnitOfWork::HINT_DEFEREAGERLOAD => true,
|
||||
'collection' => $coll
|
||||
);
|
||||
|
||||
if (isset($assoc['indexBy'])) {
|
||||
|
@ -76,6 +76,13 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*/
|
||||
const STATE_REMOVED = 4;
|
||||
|
||||
/**
|
||||
* Hint used to collect all primary keys of associated entities during hydration
|
||||
* and execute it in a dedicated query afterwards
|
||||
* @see https://doctrine-orm.readthedocs.org/en/latest/reference/dql-doctrine-query-language.html?highlight=eager#temporarily-change-fetch-mode-in-dql
|
||||
*/
|
||||
const HINT_DEFEREAGERLOAD = 'deferEagerLoad';
|
||||
|
||||
/**
|
||||
* The identity map that holds references to all managed entities that have
|
||||
* an identity. The entities are grouped by their class name.
|
||||
@ -2616,7 +2623,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
// this association is marked as eager fetch, and its an uninitialized proxy (wtf!)
|
||||
// then we can append this entity for eager loading!
|
||||
if ($hints['fetchMode'][$class->name][$field] == ClassMetadata::FETCH_EAGER &&
|
||||
isset($hints['deferEagerLoad']) &&
|
||||
isset($hints[self::HINT_DEFEREAGERLOAD]) &&
|
||||
!$targetClass->isIdentifierComposite &&
|
||||
$newValue instanceof Proxy &&
|
||||
$newValue->__isInitialized__ === false) {
|
||||
@ -2641,7 +2648,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
break;
|
||||
|
||||
// Deferred eager load only works for single identifier classes
|
||||
case (isset($hints['deferEagerLoad']) && ! $targetClass->isIdentifierComposite):
|
||||
case (isset($hints[self::HINT_DEFEREAGERLOAD]) && ! $targetClass->isIdentifierComposite):
|
||||
// TODO: Is there a faster approach?
|
||||
$this->eagerLoadingEntities[$targetClass->rootEntityName][$relatedIdHash] = current($associatedId);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user