From 110d771883bfdb215142b191243f5bf45cfe35cf Mon Sep 17 00:00:00 2001 From: Rico Humme Date: Fri, 3 Jun 2016 16:27:27 +0200 Subject: [PATCH] Split of functionality in separate functions --- lib/Doctrine/ORM/UnitOfWork.php | 50 +++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 3f0b6f7a0..1b7425d74 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2407,24 +2407,8 @@ class UnitOfWork implements PropertyChangedListener $this->commitOrderCalculator->clear(); } } else { - $visited = array(); - - foreach ($this->identityMap as $className => $entities) { - if ($className !== $entityName) { - continue; - } - - foreach ($entities as $entity) { - $this->doDetach($entity, $visited, false); - } - } - - foreach ($this->entityInsertions as $hash => $entity) { - if (get_class($entity) != $entityName) { - continue; - } - unset($this->entityInsertions[$hash]); - } + $this->clearIdentityMap($entityName); + $this->clearIdentityInsertions($entityName); } if ($this->evm->hasListeners(Events::onClear)) { @@ -3478,4 +3462,34 @@ class UnitOfWork implements PropertyChangedListener { $this->hydrationCompleteHandler->hydrationComplete(); } + + /** + * @param $entityName + */ + private function clearIdentityMap($entityName) + { + $visited = array(); + + foreach ($this->identityMap as $className => $entities) { + if ($className !== $entityName) { + continue; + } + + foreach ($entities as $entity) { + $this->doDetach($entity, $visited, false); + } + } + } + + /** + * @param $entityName + */ + private function clearIdentityInsertions($entityName) + { + foreach ($this->entityInsertions as $hash => $entity) { + if (get_class($entity) === $entityName) { + unset($this->entityInsertions[$hash]); + } + } + } }