function SectionListTrait::addBlankSection

Same name in other branches
  1. 9 core/modules/layout_builder/src/SectionListTrait.php \Drupal\layout_builder\SectionListTrait::addBlankSection()
  2. 10 core/modules/layout_builder/src/SectionListTrait.php \Drupal\layout_builder\SectionListTrait::addBlankSection()

Adds a blank section to the list.

Return value

$this

See also

\Drupal\layout_builder\Plugin\Layout\BlankLayout

2 calls to SectionListTrait::addBlankSection()
SectionListTrait::removeAllSections in core/modules/layout_builder/src/SectionListTrait.php
SectionListTrait::removeSection in core/modules/layout_builder/src/SectionListTrait.php

File

core/modules/layout_builder/src/SectionListTrait.php, line 102

Class

SectionListTrait
Provides a trait for maintaining a list of sections.

Namespace

Drupal\layout_builder

Code

protected function addBlankSection() {
    if ($this->hasSection(0)) {
        throw new \Exception('A blank section must only be added to an empty list');
    }
    $this->appendSection(new Section('layout_builder_blank'));
    return $this;
}

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