You are here

protected function LayoutSectionItemList::setSections in Drupal 8

Same name and namespace in other branches
  1. 9 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()

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 SectionStorageTrait::setSections

File

core/modules/layout_builder/src/Field/LayoutSectionItemList.php, line 46

Class

LayoutSectionItemList
Defines a 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;
}