You are here

public function LayoutDefault::build in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Layout/LayoutDefault.php \Drupal\Core\Layout\LayoutDefault::build()

Build a render array for layout with regions.

Parameters

array $regions: An associative array keyed by region name, containing render arrays representing the content that should be placed in each region.

Return value

array Render array for the layout with regions.

Overrides LayoutInterface::build

2 calls to LayoutDefault::build()
LayoutBuilderTestPlugin::build in core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestPlugin.php
Build a render array for layout with regions.
MultiWidthLayoutBase::build in core/modules/layout_builder/src/Plugin/Layout/MultiWidthLayoutBase.php
Build a render array for layout with regions.
3 methods override LayoutDefault::build()
BlankLayout::build in core/modules/layout_builder/src/Plugin/Layout/BlankLayout.php
Build a render array for layout with regions.
LayoutBuilderTestPlugin::build in core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/LayoutBuilderTestPlugin.php
Build a render array for layout with regions.
MultiWidthLayoutBase::build in core/modules/layout_builder/src/Plugin/Layout/MultiWidthLayoutBase.php
Build a render array for layout with regions.

File

core/lib/Drupal/Core/Layout/LayoutDefault.php, line 33

Class

LayoutDefault
Provides a default class for Layout plugins.

Namespace

Drupal\Core\Layout

Code

public function build(array $regions) {

  // Ensure $build only contains defined regions and in the order defined.
  $build = [];
  foreach ($this
    ->getPluginDefinition()
    ->getRegionNames() as $region_name) {
    if (array_key_exists($region_name, $regions)) {
      $build[$region_name] = $regions[$region_name];
    }
  }
  $build['#settings'] = $this
    ->getConfiguration();
  $build['#layout'] = $this->pluginDefinition;
  $build['#theme'] = $this->pluginDefinition
    ->getThemeHook();
  if ($library = $this->pluginDefinition
    ->getLibrary()) {
    $build['#attached']['library'][] = $library;
  }
  return $build;
}