1
0
mirror of synced 2025-01-29 19:41:45 +03:00

optimized PreFlush (moved into computeChangeSet function)

This commit is contained in:
everzet 2011-11-03 16:24:47 +02:00
parent 91d8829c43
commit 9c4c06c422

View File

@ -259,36 +259,6 @@ class UnitOfWork implements PropertyChangedListener
*/
public function commit($entity = null)
{
// Run preFlush lifecycle callback for new entities
foreach ($this->entityInsertions as $classEntity) {
$class = $this->em->getClassMetadata(get_class($classEntity));
// Skip class if instances are read-only
if ($class->isReadOnly) {
continue;
}
if (isset($class->lifecycleCallbacks[Events::preFlush])) {
$class->invokeLifecycleCallbacks(Events::preFlush, $classEntity);
}
}
// Run preFlush lifecycle callback for persisted entities
foreach ($this->identityMap as $className => $classEntities) {
$class = $this->em->getClassMetadata($className);
// Skip class if instances are read-only
if ($class->isReadOnly) {
continue;
}
if (isset($class->lifecycleCallbacks[Events::preFlush])) {
foreach ($classEntities as $classEntity) {
$class->invokeLifecycleCallbacks(Events::preFlush, $classEntity);
}
}
}
// Raise preFlush
if ($this->evm->hasListeners(Events::preFlush)) {
$this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->em));
@ -516,6 +486,11 @@ class UnitOfWork implements PropertyChangedListener
return;
}
// Fire PreFlush lifecycle callbacks
if (isset($class->lifecycleCallbacks[Events::preFlush])) {
$class->invokeLifecycleCallbacks(Events::preFlush, $entity);
}
$actualData = array();
foreach ($class->reflFields as $name => $refProp) {
$value = $refProp->getValue($entity);