You are here

protected function LayoutBuilderEntityViewDisplay::setSections in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::setSections()
  2. 9 core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::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/Entity/LayoutBuilderEntityViewDisplay.php, line 109

Class

LayoutBuilderEntityViewDisplay
Provides an entity view display entity that has a layout.

Namespace

Drupal\layout_builder\Entity

Code

protected function setSections(array $sections) {

  // Third-party settings must be completely unset instead of stored as an
  // empty array.
  if (!$sections) {
    $this
      ->unsetThirdPartySetting('layout_builder', 'sections');
  }
  else {
    $this
      ->setThirdPartySetting('layout_builder', 'sections', array_values($sections));
  }
  return $this;
}