public function LayoutParagraphsLayout::reorderComponents in Layout Paragraphs 2.0.x
Reorder components.
Accepts an associative of component uuids, parent uuids, and regions.
Parameters
array $ordered_items: The nested array with the new order for items.
Return value
$this
File
- src/
LayoutParagraphsLayout.php, line 317
Class
- LayoutParagraphsLayout
- Provides a domain object for a complete Layout Paragraphs Layout.
Namespace
Drupal\layout_paragraphsCode
public function reorderComponents(array $ordered_items) {
foreach ($ordered_items as $ordered_item) {
if ($component = $this
->getComponentByUuid($ordered_item['uuid'])) {
$component
->setSettings([
'parent_uuid' => $ordered_item['parentUuid'],
'region' => $ordered_item['region'],
]);
$reordered_items[] = [
'entity' => $component
->getEntity(),
];
}
}
$this->paragraphsReferenceField
->setValue($reordered_items);
return $this;
}