You are here

public function LayoutDefault::build in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Layout/LayoutDefault.php \Drupal\Core\Layout\LayoutDefault::build()
  2. 9 core/lib/Drupal/Core/Layout/LayoutDefault.php \Drupal\Core\Layout\LayoutDefault::build()
2 methods override 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.
TestContextAwareLayout::build in core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php
Build a render array for layout with regions.

File

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

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