[Form] fix failing tests for remove call on an objectCollection
This commit is contained in:
parent
076a104e86
commit
9215c4478f
@ -489,6 +489,7 @@ class PropertyPath implements \IteratorAggregate
|
||||
// Collection with matching adder/remover in $objectOrArray
|
||||
if ($addMethod && $removeMethod) {
|
||||
$itemsToAdd = is_object($value) ? clone $value : $value;
|
||||
$itemToRemove = array();
|
||||
$previousValue = $this->readProperty($objectOrArray, $currentIndex);
|
||||
|
||||
if (is_array($previousValue) || $previousValue instanceof Traversable) {
|
||||
@ -503,11 +504,15 @@ class PropertyPath implements \IteratorAggregate
|
||||
}
|
||||
}
|
||||
|
||||
// Item not found, remove
|
||||
$objectOrArray->$removeMethod($previousItem);
|
||||
// Item not found, add to remove list
|
||||
$itemToRemove[] = $previousItem;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($itemToRemove as $item) {
|
||||
$objectOrArray->$removeMethod($item);
|
||||
}
|
||||
|
||||
foreach ($itemsToAdd as $item) {
|
||||
$objectOrArray->$addMethod($item);
|
||||
}
|
||||
|
Reference in New Issue
Block a user