function LayoutBuilder::prepareLayout

Same name in other branches
  1. 9 core/modules/layout_builder/src/Element/LayoutBuilder.php \Drupal\layout_builder\Element\LayoutBuilder::prepareLayout()
  2. 10 core/modules/layout_builder/src/Element/LayoutBuilder.php \Drupal\layout_builder\Element\LayoutBuilder::prepareLayout()
  3. 11.x core/modules/layout_builder/src/Element/LayoutBuilder.php \Drupal\layout_builder\Element\LayoutBuilder::prepareLayout()

Prepares a layout for use in the UI.

Parameters

\Drupal\layout_builder\SectionStorageInterface $section_storage: The section storage.

1 call to LayoutBuilder::prepareLayout()
LayoutBuilder::layout in core/modules/layout_builder/src/Element/LayoutBuilder.php
Renders the Layout UI.

File

core/modules/layout_builder/src/Element/LayoutBuilder.php, line 147

Class

LayoutBuilder
Defines a render element for building the Layout Builder UI.

Namespace

Drupal\layout_builder\Element

Code

protected function prepareLayout(SectionStorageInterface $section_storage) {
    // If the layout has pending changes, add a warning.
    if ($this->layoutTempstoreRepository
        ->has($section_storage)) {
        $this->messenger
            ->addWarning($this->t('You have unsaved changes.'));
    }
    elseif ($section_storage instanceof OverridesSectionStorageInterface && !$section_storage->isOverridden()) {
        $sections = $section_storage->getDefaultSectionStorage()
            ->getSections();
        foreach ($sections as $section) {
            $section_storage->appendSection($section);
        }
        $this->layoutTempstoreRepository
            ->set($section_storage);
    }
}

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