layout_builder.module

Same filename in other branches
  1. 9 core/modules/layout_builder/layout_builder.module
  2. 8.9.x core/modules/layout_builder/layout_builder.module
  3. 10 core/modules/layout_builder/layout_builder.module

File

core/modules/layout_builder/layout_builder.module

View source
<?php


/**
 * @file
 */
use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage;

/**
 * Implements hook_module_implements_alter().
 */
function layout_builder_module_implements_alter(&$implementations, $hook) {
    if ($hook === 'entity_view_alter') {
        // Ensure that this module's implementation of hook_entity_view_alter() runs
        // last so that other modules that use this hook to render extra fields will
        // run before it.
        $group = $implementations['layout_builder'];
        unset($implementations['layout_builder']);
        $implementations['layout_builder'] = $group;
    }
}

/**
 * Implements hook_preprocess_HOOK() for language-content-settings-table.html.twig.
 */
function layout_builder_preprocess_language_content_settings_table(&$variables) : void {
    foreach ($variables['build']['#rows'] as &$row) {
        if (isset($row['#field_name']) && $row['#field_name'] === OverridesSectionStorage::FIELD_NAME) {
            // Rebuild the label to include a warning about using translations with
            // layouts.
            $row['data'][1]['data']['field'] = [
                'label' => $row['data'][1]['data']['field'],
                'description' => [
                    '#type' => 'container',
                    '#markup' => t('<strong>Warning</strong>: Layout Builder does not support translating layouts. (<a href="https://www.drupal.org/docs/8/core/modules/layout-builder/layout-builder-and-content-translation">online documentation</a>)'),
                    '#attributes' => [
                        'class' => [
                            'layout-builder-translation-warning',
                        ],
                    ],
                ],
            ];
        }
    }
}

Functions

Title Deprecated Summary
layout_builder_module_implements_alter Implements hook_module_implements_alter().
layout_builder_preprocess_language_content_settings_table Implements hook_preprocess_HOOK() for language-content-settings-table.html.twig.

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