Merge branch 'DDC-958'
This commit is contained in:
commit
961cb6e9a3
@ -28,7 +28,9 @@ use PDO,
|
|||||||
Doctrine\ORM\Query,
|
Doctrine\ORM\Query,
|
||||||
Doctrine\ORM\PersistentCollection,
|
Doctrine\ORM\PersistentCollection,
|
||||||
Doctrine\ORM\Mapping\MappingException,
|
Doctrine\ORM\Mapping\MappingException,
|
||||||
Doctrine\ORM\Mapping\ClassMetadata;
|
Doctrine\ORM\Mapping\ClassMetadata,
|
||||||
|
Doctrine\ORM\Events,
|
||||||
|
Doctrine\ORM\Event\LifecycleEventArgs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A BasicEntityPersiter maps an entity to a single table in a relational database.
|
* A BasicEntityPersiter maps an entity to a single table in a relational database.
|
||||||
@ -704,6 +706,14 @@ class BasicEntityPersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->_em->getUnitOfWork()->setOriginalEntityData($entity, $newData);
|
$this->_em->getUnitOfWork()->setOriginalEntityData($entity, $newData);
|
||||||
|
|
||||||
|
if (isset($this->_class->lifecycleCallbacks[Events::postLoad])) {
|
||||||
|
$this->_class->invokeLifecycleCallbacks(Events::postLoad, $entity);
|
||||||
|
}
|
||||||
|
$evm = $this->_em->getEventManager();
|
||||||
|
if ($evm->hasListeners(Events::postLoad)) {
|
||||||
|
$evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($entity, $this->_em));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,6 +82,27 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$this->assertTrue($reference->postLoadCallbackInvoked);
|
$this->assertTrue($reference->postLoadCallbackInvoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-958
|
||||||
|
*/
|
||||||
|
public function testPostLoadTriggeredOnRefresh()
|
||||||
|
{
|
||||||
|
$entity = new LifecycleCallbackTestEntity;
|
||||||
|
$entity->value = 'hello';
|
||||||
|
$this->_em->persist($entity);
|
||||||
|
$this->_em->flush();
|
||||||
|
$id = $entity->getId();
|
||||||
|
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$reference = $this->_em->find('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id);
|
||||||
|
$this->assertTrue($reference->postLoadCallbackInvoked);
|
||||||
|
$reference->postLoadCallbackInvoked = false;
|
||||||
|
|
||||||
|
$this->_em->refresh($reference);
|
||||||
|
$this->assertTrue($reference->postLoadCallbackInvoked, "postLoad should be invoked when refresh() is called.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-113
|
* @group DDC-113
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user