function LayoutBuilderEntityViewDisplay::getDefaultSection

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

Gets a default section.

Return value

\Drupal\layout_builder\Section The default section.

1 call to LayoutBuilderEntityViewDisplay::getDefaultSection()
LayoutBuilderEntityViewDisplay::setComponent in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Sets the display options for a component.

File

core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php, line 451

Class

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

Namespace

Drupal\layout_builder\Entity

Code

protected function getDefaultSection() {
    // If no section exists, append a new one.
    if (!$this->hasSection(0)) {
        $this->appendSection(new Section('layout_onecol'));
    }
    // Return the first section.
    return $this->getSection(0);
}

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