[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
|
// Collection with matching adder/remover in $objectOrArray
|
||||||
if ($addMethod && $removeMethod) {
|
if ($addMethod && $removeMethod) {
|
||||||
$itemsToAdd = is_object($value) ? clone $value : $value;
|
$itemsToAdd = is_object($value) ? clone $value : $value;
|
||||||
|
$itemToRemove = array();
|
||||||
$previousValue = $this->readProperty($objectOrArray, $currentIndex);
|
$previousValue = $this->readProperty($objectOrArray, $currentIndex);
|
||||||
|
|
||||||
if (is_array($previousValue) || $previousValue instanceof Traversable) {
|
if (is_array($previousValue) || $previousValue instanceof Traversable) {
|
||||||
@ -503,11 +504,15 @@ class PropertyPath implements \IteratorAggregate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item not found, remove
|
// Item not found, add to remove list
|
||||||
$objectOrArray->$removeMethod($previousItem);
|
$itemToRemove[] = $previousItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($itemToRemove as $item) {
|
||||||
|
$objectOrArray->$removeMethod($item);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($itemsToAdd as $item) {
|
foreach ($itemsToAdd as $item) {
|
||||||
$objectOrArray->$addMethod($item);
|
$objectOrArray->$addMethod($item);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user