Version 1
[yaffs-website] / web / core / modules / layout_discovery / layout_discovery.module
1 <?php
2
3 /**
4  * @file
5  * Provides hook implementations for Layout Discovery.
6  */
7
8 /**
9  * Implements hook_help().
10  */
11 function layout_discovery_help($route_name) {
12   switch ($route_name) {
13     case 'help.page.layout_discovery':
14       $output = '<h3>' . t('About') . '</h3>';
15       $output .= '<p>' . t('Layout Discovery allows modules or themes to register layouts, and for other modules to list the available layouts and render them.') . '</p>';
16       $output .= '<p>' . t('For more information, see the <a href=":layout-discovery-documentation">online documentation for the Layout Discovery module</a>.', [':layout-discovery-documentation' => 'https://www.drupal.org/node/2619128']) . '</p>';
17       return $output;
18   }
19 }
20
21 /**
22  * Implements hook_theme().
23  */
24 function layout_discovery_theme() {
25   return \Drupal::service('plugin.manager.core.layout')->getThemeImplementations();
26 }
27
28 /**
29  * Prepares variables for layout templates.
30  *
31  * @param array &$variables
32  *   An associative array containing:
33  *   - content: An associative array containing the properties of the element.
34  *     Properties used: #settings, #layout.
35  */
36 function template_preprocess_layout(&$variables) {
37   $variables['settings'] = isset($variables['content']['#settings']) ? $variables['content']['#settings'] : [];
38   $variables['layout'] = isset($variables['content']['#layout']) ? $variables['content']['#layout'] : [];
39 }