protected function LayoutSectionItemList::setSections in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::setSections()
- 9 core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::setSections()
Stores the information for all sections.
Implementations of this method are expected to call array_values() to rekey the list of sections.
Parameters
\Drupal\layout_builder\Section[] $sections: An array of section objects.
Return value
$this
Overrides SectionListTrait::setSections
File
- core/
modules/ layout_builder/ src/ Field/ LayoutSectionItemList.php, line 46
Class
- LayoutSectionItemList
- Defines an item list class for layout section fields.
Namespace
Drupal\layout_builder\FieldCode
protected function setSections(array $sections) {
$this->list = [];
$sections = array_values($sections);
/** @var \Drupal\layout_builder\Plugin\Field\FieldType\LayoutSectionItem $item */
foreach ($sections as $section) {
$item = $this
->appendItem();
$item->section = $section;
}
return $this;
}