5 * Hook implementations for Layout Plugin module.
8 use \Drupal\Core\Routing\RouteMatchInterface;
9 use \Drupal\layout_plugin\Layout;
12 * Implements hook_help();
14 function layout_plugin_help($route_name, RouteMatchInterface $route_match) {
15 switch ($route_name) {
16 case 'help.page.layout_plugin':
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>';
29 * Implements hook_theme().
31 function layout_plugin_theme() {
32 return Layout::layoutPluginManager()->getThemeImplementations();
36 * Implements hook_theme_registry_alter().
38 function layout_plugin_theme_registry_alter(&$theme_registry) {
39 Layout::layoutPluginManager()->alterThemeImplementations($theme_registry);
43 * Implements hook_library_info_build().
45 function layout_plugin_library_info_build() {
46 return Layout::layoutPluginManager()->getLibraryInfo();
50 * Prepares variables for layout templates.
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.
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
60 function _layout_plugin_preprocess_layout(&$variables) {
61 $content = $variables['content'];
62 $variables['settings'] = $content['#settings'] ?: [];
63 $variables['layout'] = $content['#layout'] ?: [];