1
0
mirror of synced 2025-02-09 00:39:25 +03:00

Split of functionality in separate functions

This commit is contained in:
Rico Humme 2016-06-03 16:27:27 +02:00 committed by Marco Pivetta
parent 996c5048ab
commit 110d771883

View File

@ -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]);
}
}
}
}