1
0
mirror of synced 2025-01-20 23:41:39 +03:00

[2.0] DDC-358 - Refactored UnitOfWork Event triggering capabilities - Revert preUpdate change - Its not good!

This commit is contained in:
beberlei 2010-02-23 20:36:07 +00:00
parent 82e42123de
commit 50190c64d3

View File

@ -541,20 +541,6 @@ class UnitOfWork implements PropertyChangedListener
$this->_originalEntityData[$oid] = $actualData; $this->_originalEntityData[$oid] = $actualData;
if ($entityIsDirty) { if ($entityIsDirty) {
$hasPreUpdateListeners = $this->_evm->hasListeners(Events::preUpdate);
if (isset($class->lifecycleCallbacks[Events::preUpdate])) {
$class->invokeLifecycleCallbacks(Events::preUpdate, $entity);
if ( ! $hasPreUpdateListeners) {
// Need to recompute entity changeset to detect changes made in the callback.
$this->recomputeSingleEntityChangeSet($class, $entity);
}
}
if ($hasPreUpdateListeners) {
$this->_evm->dispatchEvent(Events::preUpdate, new LifecycleEventArgs($entity, $this->_em));
// Need to recompute entity changeset to detect changes made in the listener.
$this->recomputeSingleEntityChangeSet($class, $entity);
}
$this->_entityUpdates[$oid] = $entity; $this->_entityUpdates[$oid] = $entity;
} }
} }
@ -751,11 +737,27 @@ class UnitOfWork implements PropertyChangedListener
$className = $class->name; $className = $class->name;
$persister = $this->getEntityPersister($className); $persister = $this->getEntityPersister($className);
$hasPreUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::preUpdate]);
$hasPreUpdateListeners = $this->_evm->hasListeners(Events::preUpdate);
$hasPostUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postUpdate]); $hasPostUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postUpdate]);
$hasPostUpdateListeners = $this->_evm->hasListeners(Events::postUpdate); $hasPostUpdateListeners = $this->_evm->hasListeners(Events::postUpdate);
foreach ($this->_entityUpdates as $oid => $entity) { foreach ($this->_entityUpdates as $oid => $entity) {
if (get_class($entity) == $className || $entity instanceof Proxy && $entity instanceof $className) { if (get_class($entity) == $className || $entity instanceof Proxy && $entity instanceof $className) {
if ($hasPreUpdateLifecycleCallbacks) {
$class->invokeLifecycleCallbacks(Events::preUpdate, $entity);
if ( ! $hasPreUpdateListeners) {
// Need to recompute entity changeset to detect changes made in the callback.
$this->recomputeSingleEntityChangeSet($class, $entity);
}
}
if ($hasPreUpdateListeners) {
$this->_evm->dispatchEvent(Events::preUpdate, new LifecycleEventArgs($entity, $this->_em));
// Need to recompute entity changeset to detect changes made in the listener.
$this->recomputeSingleEntityChangeSet($class, $entity);
}
$persister->update($entity); $persister->update($entity);
unset($this->_entityUpdates[$oid]); unset($this->_entityUpdates[$oid]);