function LayoutSectionItemList::setSections

Same name in other branches
  1. 8.9.x core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::setSections()
  2. 10 core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::setSections()
  3. 11.x core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::setSections()

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\Field

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.