1
0
mirror of synced 2025-03-20 06:53:55 +03:00

#470 DDC-54 DDC-3005 - reverting hydrator changes, as patch DDC-3005 already deals with the issue

This commit is contained in:
Marco Pivetta 2015-01-13 01:09:23 +01:00
parent aa4796cd0d
commit b1144e74ea
2 changed files with 2 additions and 51 deletions

View File

@ -77,18 +77,11 @@ class ObjectHydrator extends AbstractHydrator
*/ */
private $existingCollections = array(); private $existingCollections = array();
/**
* @var \Doctrine\ORM\Event\PostLoadEventDispatcher
*/
private $postLoadEventDispatcher;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function prepare() protected function prepare()
{ {
$this->postLoadEventDispatcher = new PostLoadEventDispatcher($this->_em, $this->_hints);
if ( ! isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) { if ( ! isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) {
$this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true; $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true;
} }
@ -154,8 +147,6 @@ class ObjectHydrator extends AbstractHydrator
$this->existingCollections = $this->existingCollections =
$this->resultPointers = array(); $this->resultPointers = array();
unset($this->postLoadEventDispatcher);
if ($eagerLoad) { if ($eagerLoad) {
$this->_uow->triggerEagerLoads(); $this->_uow->triggerEagerLoads();
} }
@ -179,8 +170,6 @@ class ObjectHydrator extends AbstractHydrator
$coll->takeSnapshot(); $coll->takeSnapshot();
} }
$this->postLoadEventDispatcher->dispatchEnqueuedPostLoadEvents();
return $result; return $result;
} }
@ -281,13 +270,7 @@ class ObjectHydrator extends AbstractHydrator
$this->_hints['fetchAlias'] = $dqlAlias; $this->_hints['fetchAlias'] = $dqlAlias;
$created = false; return $this->_uow->createEntity($className, $data, $this->_hints);
$entity = $this->_uow->createEntity($className, $data, $this->_hints, $created);
if ($created) {
$this->postLoadEventDispatcher->dispatchPostLoad($entity);
}
return $entity;
} }
/** /**

View File

@ -23,10 +23,6 @@ use PDO;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\Events;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\ListenersInvoker;
use Doctrine\ORM\Event\PostLoadEventDispatcher;
class SimpleObjectHydrator extends AbstractHydrator class SimpleObjectHydrator extends AbstractHydrator
{ {
@ -35,23 +31,11 @@ class SimpleObjectHydrator extends AbstractHydrator
*/ */
private $class; private $class;
/**
* @var \Doctrine\ORM\Event\PostLoadEventDispatcher
*/
private $postLoadEventDispatcher;
/**
* @var array
*/
private $hydratedObjects = array();
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function prepare() protected function prepare()
{ {
$this->postLoadEventDispatcher = new PostLoadEventDispatcher($this->_em, $this->_hints);
if (count($this->_rsm->aliasMap) !== 1) { if (count($this->_rsm->aliasMap) !== 1) {
throw new \RuntimeException("Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result."); throw new \RuntimeException("Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result.");
} }
@ -87,21 +71,9 @@ class SimpleObjectHydrator extends AbstractHydrator
$this->_em->getUnitOfWork()->triggerEagerLoads(); $this->_em->getUnitOfWork()->triggerEagerLoads();
$this->postLoadEventDispatcher->dispatchEnqueuedPostLoadEvents();
return $result; return $result;
} }
/**
* {@inheritdoc}
*/
protected function cleanup()
{
parent::cleanup();
unset($this->postLoadEventDispatcher);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -169,11 +141,7 @@ class SimpleObjectHydrator extends AbstractHydrator
} }
$uow = $this->_em->getUnitOfWork(); $uow = $this->_em->getUnitOfWork();
$created = false; $entity = $uow->createEntity($entityName, $data, $this->_hints);
$entity = $uow->createEntity($entityName, $data, $this->_hints, $created);
if ($created) {
$this->postLoadEventDispatcher->dispatchPostLoad($entity);
}
$result[] = $entity; $result[] = $entity;
} }