protected function GeysirModalParagraphAddForm::reorderItemList in Geysir 8
Reorder the ItemList in the parent entity.
1 call to GeysirModalParagraphAddForm::reorderItemList()
- GeysirModalParagraphAddForm::save in src/
Form/ GeysirModalParagraphAddForm.php - Form submission handler for the 'save' action.
File
- src/
Form/ GeysirModalParagraphAddForm.php, line 58
Class
- GeysirModalParagraphAddForm
- Functionality to edit a paragraph through a modal.
Namespace
Drupal\geysir\FormCode
protected function reorderItemList($parent_entity) {
$route_match = $this
->getRouteMatch();
$field = $route_match
->getParameter('field');
$delta = $route_match
->getParameter('delta');
$list_items = $parent_entity
->get($field)
->getIterator();
for ($index = $parent_entity
->get($field)
->count() - 1; $index >= 0; $index--) {
$parent_entity
->get($field)
->removeItem($index);
}
foreach ($list_items as $item_delta => $item) {
if ($item_delta == $delta) {
$this
->insertItemIntoList($parent_entity, $item);
}
else {
$parent_entity
->get($field)
->appendItem($item
->getValue());
}
}
}