class LayoutBuilderThemeHooks

Hook implementations for layout_builder.

Hierarchy

Expanded class hierarchy of LayoutBuilderThemeHooks

File

core/modules/layout_builder/src/Hook/LayoutBuilderThemeHooks.php, line 12

Namespace

Drupal\layout_builder\Hook
View source
class LayoutBuilderThemeHooks {
  use StringTranslationTrait;
  
  /**
   * Implements hook_preprocess_HOOK() for language-content-settings-table.html.twig.
   */
  public function preprocessLanguageContentSettingsTable(&$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' => $this->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',
              ],
            ],
          ],
        ];
      }
    }
  }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
LayoutBuilderThemeHooks::preprocessLanguageContentSettingsTable public function Implements hook_preprocess_HOOK() for language-content-settings-table.html.twig.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language. 1

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