protected function GeysirModalParagraphAddForm::insertItemIntoList in Geysir 8
Insert the value into the ItemList either before or after.
1 call to GeysirModalParagraphAddForm::insertItemIntoList()
- GeysirModalParagraphAddForm::reorderItemList in src/
Form/ GeysirModalParagraphAddForm.php - Reorder the ItemList in the parent entity.
File
- src/
Form/ GeysirModalParagraphAddForm.php, line 82
Class
- GeysirModalParagraphAddForm
- Functionality to edit a paragraph through a modal.
Namespace
Drupal\geysir\FormCode
protected function insertItemIntoList($parent_entity, $item) {
$route_match = $this
->getRouteMatch();
$field = $route_match
->getParameter('field');
$position = $route_match
->getParameter('position');
$value = [
'target_id' => $this->entity
->id(),
'target_revision_id' => $this->entity
->getRevisionId(),
];
if ($position == 'before') {
$parent_entity
->get($field)
->appendItem($value);
$parent_entity
->get($field)
->appendItem($item
->getValue());
}
else {
$parent_entity
->get($field)
->appendItem($item
->getValue());
$parent_entity
->get($field)
->appendItem($value);
}
}