Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / layout_plugin / layout_plugin.module
1 <?php
2
3 /**
4  * @file
5  * Hook implementations for Layout Plugin module.
6  */
7
8 use \Drupal\Core\Routing\RouteMatchInterface;
9 use \Drupal\layout_plugin\Layout;
10
11 /**
12  * Implements hook_help();
13  */
14 function layout_plugin_help($route_name, RouteMatchInterface $route_match) {
15   switch ($route_name) {
16     case 'help.page.layout_plugin':
17       $output = '';
18       $output .= '<h3>' . t('About') . '</h3>';
19       $output .= '<p>' . t('Layout Plugin allows modules or themes to register layouts, and for other modules to list the available layouts and render them. For more information, see the <a href=":layout-plugin-documentation">online documentation for the Layout Plugin module</a>.', [':layout-plugin-documentation' => 'https://www.drupal.org/node/2619128']) . '</p>';
20       $output .= '<h3>' . t('Uses') . '</h3>';
21       $output .= '<p>' . t('This is an API module which serves as the plugin manager for layouts. API modules provide a common set of routines, protocols, and tools developers use for building specific features into modules for your site. See the Layout Plugin project page for a complete listing of <a href=":layout_plugin">Modules that use Layout Plugin</a>.', [':layout_plugin' => 'https://www.drupal.org/project/layout_plugin'])  . '</p>';
22       $output .= '<p>' . t('<em>Registering</em> a Layout Plugin - There are several ways to register your layout. For more information of the simplest, most common case and then building up to some of the more advanced techniques, see <a href=":register">How to register layouts with Layout Plugin</a>.', [':layout_plugin' => 'https://www.drupal.org/node/2578731'])  . '</p>';
23       $output .= '<p>' . t('<em>Rendering</em>  a Layout Plugin -  To render a layout plugin you first get the layout plugin manager, then list available layouts and instantiate the layout plugin.  Rendering is then possible and a configuration display for showing and storing layouts is made available. For more information on rendering layouts, see  <a href=":render">How to render layouts using Layout Plugin</a>.', [':layout_plugin' => 'https://www.drupal.org/node/2619168'])  . '</p>';
24       return $output;
25   }
26 }
27
28 /**
29  * Implements hook_theme().
30  */
31 function layout_plugin_theme() {
32   return Layout::layoutPluginManager()->getThemeImplementations();
33 }
34
35 /**
36  * Implements hook_theme_registry_alter().
37  */
38 function layout_plugin_theme_registry_alter(&$theme_registry) {
39   Layout::layoutPluginManager()->alterThemeImplementations($theme_registry);
40 }
41
42 /**
43  * Implements hook_library_info_build().
44  */
45 function layout_plugin_library_info_build() {
46   return Layout::layoutPluginManager()->getLibraryInfo();
47 }
48
49 /**
50  * Prepares variables for layout templates.
51  *
52  * We name it with an underscore so if there is ever a template called 'layout'
53  * that this preprocess function doesn't automatically get picked up.
54  *
55  * @param array &$variables
56  *   An associative array containing:
57  *   - element: An associative array containing the properties of the element.
58  *     Properties used: #settings, #layout
59  */
60 function _layout_plugin_preprocess_layout(&$variables) {
61   $content = $variables['content'];
62   $variables['settings'] = $content['#settings'] ?: [];
63   $variables['layout'] = $content['#layout'] ?: [];
64 }