function template_preprocess_layout

Same name in other branches
  1. 9 core/modules/layout_discovery/layout_discovery.module \template_preprocess_layout()
  2. 10 core/modules/layout_discovery/layout_discovery.module \template_preprocess_layout()
  3. 11.x core/modules/layout_discovery/layout_discovery.module \template_preprocess_layout()

Prepares variables for layout templates.

Parameters

array &$variables: An associative array containing:

  • content: An associative array containing the properties of the element. Properties used: #settings, #layout.
1 string reference to 'template_preprocess_layout'
LayoutTest::testThemeProvidedLayout in core/modules/layout_discovery/tests/src/Kernel/LayoutTest.php
Tests that a layout provided by a theme has the preprocess function set.

File

core/modules/layout_discovery/layout_discovery.module, line 39

Code

function template_preprocess_layout(&$variables) {
    $variables['settings'] = isset($variables['content']['#settings']) ? $variables['content']['#settings'] : [];
    $variables['layout'] = isset($variables['content']['#layout']) ? $variables['content']['#layout'] : [];
    // Create an attributes variable for each region.
    foreach (Element::children($variables['content']) as $name) {
        if (!isset($variables['content'][$name]['#attributes'])) {
            $variables['content'][$name]['#attributes'] = [];
        }
        $variables['region_attributes'][$name] = new Attribute($variables['content'][$name]['#attributes']);
    }
}

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