#1521 DDC-2922 minor code cleanup - renaming internal private methods, variables, removing redundant if/else
This commit is contained in:
parent
87e8bccb11
commit
2751c0fff2
@ -187,9 +187,9 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
* Keys are OIDs, payload is a two-item array describing the association
|
* Keys are OIDs, payload is a two-item array describing the association
|
||||||
* and the entity.
|
* and the entity.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var object[][]|array[][] indexed by respective object spl_object_hash()
|
||||||
*/
|
*/
|
||||||
private $newEntitiesWithoutCascade = array();
|
private $nonCascadedNewDetectedEntities = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All pending collection deletions.
|
* All pending collection deletions.
|
||||||
@ -347,7 +347,8 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertNoCascadingGaps();
|
// @TODO move this further down
|
||||||
|
$this->assertThatThereAreNoUnintentionallyNonPersistedAssociations();
|
||||||
|
|
||||||
if ( ! ($this->entityInsertions ||
|
if ( ! ($this->entityInsertions ||
|
||||||
$this->entityDeletions ||
|
$this->entityDeletions ||
|
||||||
@ -442,7 +443,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
$this->entityDeletions =
|
$this->entityDeletions =
|
||||||
$this->extraUpdates =
|
$this->extraUpdates =
|
||||||
$this->collectionUpdates =
|
$this->collectionUpdates =
|
||||||
$this->newEntitiesWithoutCascade =
|
$this->nonCascadedNewDetectedEntities =
|
||||||
$this->collectionDeletions =
|
$this->collectionDeletions =
|
||||||
$this->visitedCollections =
|
$this->visitedCollections =
|
||||||
$this->orphanRemovals = [];
|
$this->orphanRemovals = [];
|
||||||
@ -883,11 +884,14 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
* through the object-graph where cascade-persistence
|
* through the object-graph where cascade-persistence
|
||||||
* is enabled for this object.
|
* is enabled for this object.
|
||||||
*/
|
*/
|
||||||
$this->newEntitiesWithoutCascade[spl_object_hash($entry)] = array($assoc,$entry);
|
$this->nonCascadedNewDetectedEntities[\spl_object_hash($entry)] = [$assoc, $entry];
|
||||||
}else {
|
|
||||||
$this->persistNew($targetClass, $entry);
|
break;
|
||||||
$this->computeChangeSet($targetClass, $entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->persistNew($targetClass, $entry);
|
||||||
|
$this->computeChangeSet($targetClass, $entry);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATE_REMOVED:
|
case self::STATE_REMOVED:
|
||||||
@ -2433,7 +2437,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
$this->entityInsertions =
|
$this->entityInsertions =
|
||||||
$this->entityUpdates =
|
$this->entityUpdates =
|
||||||
$this->entityDeletions =
|
$this->entityDeletions =
|
||||||
$this->newEntitiesWithoutCascade =
|
$this->nonCascadedNewDetectedEntities =
|
||||||
$this->collectionDeletions =
|
$this->collectionDeletions =
|
||||||
$this->collectionUpdates =
|
$this->collectionUpdates =
|
||||||
$this->extraUpdates =
|
$this->extraUpdates =
|
||||||
@ -3388,21 +3392,16 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that there are no new entities found through non-cascade-persist
|
|
||||||
* paths which are not also scheduled for insertion through valid paths.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @throws ORMInvalidArgumentException
|
* @throws ORMInvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function assertNoCascadingGaps()
|
private function assertThatThereAreNoUnintentionallyNonPersistedAssociations() : void
|
||||||
{
|
{
|
||||||
/**
|
$entitiesNeedingCascadePersist = \array_diff_key($this->nonCascadedNewDetectedEntities, $this->entityInsertions);
|
||||||
* Filter out any entities that we (successfully) managed to schedule
|
|
||||||
* for insertion.
|
if($entitiesNeedingCascadePersist){
|
||||||
*/
|
[$assoc, $entity] = \array_values($entitiesNeedingCascadePersist)[0];
|
||||||
$entitiesNeedingCascadePersist = array_diff_key($this->newEntitiesWithoutCascade, $this->entityInsertions);
|
|
||||||
if(count($entitiesNeedingCascadePersist) > 0){
|
// @TODO internal clean up here
|
||||||
list($assoc,$entity) = array_values($entitiesNeedingCascadePersist)[0];
|
|
||||||
throw ORMInvalidArgumentException::newEntityFoundThroughRelationship($assoc, $entity);
|
throw ORMInvalidArgumentException::newEntityFoundThroughRelationship($assoc, $entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user