You are here

protected function LayoutBuilderEntityViewDisplay::getDefaultSection in Drupal 8

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

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 475

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