3 namespace Drupal\Core\Layout;
5 use Drupal\Component\Utility\NestedArray;
6 use Drupal\Core\Plugin\PluginBase;
9 * Provides a default class for Layout plugins.
11 class LayoutDefault extends PluginBase implements LayoutInterface {
14 * The layout definition.
16 * @var \Drupal\Core\Layout\LayoutDefinition
18 protected $pluginDefinition;
23 public function __construct(array $configuration, $plugin_id, $plugin_definition) {
24 parent::__construct($configuration, $plugin_id, $plugin_definition);
25 $this->setConfiguration($configuration);
31 public function build(array $regions) {
32 // Ensure $build only contains defined regions and in the order defined.
34 foreach ($this->getPluginDefinition()->getRegionNames() as $region_name) {
35 if (array_key_exists($region_name, $regions)) {
36 $build[$region_name] = $regions[$region_name];
39 $build['#settings'] = $this->getConfiguration();
40 $build['#layout'] = $this->pluginDefinition;
41 $build['#theme'] = $this->pluginDefinition->getThemeHook();
42 if ($library = $this->pluginDefinition->getLibrary()) {
43 $build['#attached']['library'][] = $library;
51 public function getConfiguration() {
52 return $this->configuration;
58 public function setConfiguration(array $configuration) {
59 $this->configuration = NestedArray::mergeDeep($this->defaultConfiguration(), $configuration);
65 public function defaultConfiguration() {
72 public function calculateDependencies() {
79 * @return \Drupal\Core\Layout\LayoutDefinition
81 public function getPluginDefinition() {
82 return parent::getPluginDefinition();