optimized PreFlush (moved into computeChangeSet function)
This commit is contained in:
parent
91d8829c43
commit
9c4c06c422
@ -259,36 +259,6 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
*/
|
*/
|
||||||
public function commit($entity = null)
|
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
|
// Raise preFlush
|
||||||
if ($this->evm->hasListeners(Events::preFlush)) {
|
if ($this->evm->hasListeners(Events::preFlush)) {
|
||||||
$this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->em));
|
$this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->em));
|
||||||
@ -516,6 +486,11 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fire PreFlush lifecycle callbacks
|
||||||
|
if (isset($class->lifecycleCallbacks[Events::preFlush])) {
|
||||||
|
$class->invokeLifecycleCallbacks(Events::preFlush, $entity);
|
||||||
|
}
|
||||||
|
|
||||||
$actualData = array();
|
$actualData = array();
|
||||||
foreach ($class->reflFields as $name => $refProp) {
|
foreach ($class->reflFields as $name => $refProp) {
|
||||||
$value = $refProp->getValue($entity);
|
$value = $refProp->getValue($entity);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user