class LayoutBuilderTestThemeHooks

Theme hook implementations for layout_builder_test.

Hierarchy

Expanded class hierarchy of LayoutBuilderTestThemeHooks

File

core/modules/layout_builder/tests/modules/layout_builder_test/src/Hook/LayoutBuilderTestThemeHooks.php, line 13

Namespace

Drupal\layout_builder_test\Hook
View source
class LayoutBuilderTestThemeHooks {
  public function __construct(protected readonly UuidInterface $uuid) {
  }
  
  /**
   * Implements hook_theme().
   */
  public function theme() : array {
    return [
      'block__preview_aware_block' => [
        'base hook' => 'block',
      ],
    ];
  }
  
  /**
   * Implements hook_preprocess_HOOK() for one-column layout template.
   */
  public function layoutOneCol(&$vars) : void {
    if (!empty($vars['content']['#entity'])) {
      $vars['content']['content'][$this->uuid
        ->generate()] = [
        '#type' => 'markup',
        '#markup' => sprintf('Yes, I can access the %s', $vars['content']['#entity']->label()),
      ];
    }
  }
  
  /**
   * Implements hook_preprocess_HOOK() for two-column layout template.
   */
  public function layoutTwocolSection(&$vars) : void {
    if (!empty($vars['content']['#entity'])) {
      $vars['content']['first'][$this->uuid
        ->generate()] = [
        '#type' => 'markup',
        '#markup' => sprintf('Yes, I can access the entity %s in two column', $vars['content']['#entity']->label()),
      ];
    }
  }

}

Members

Title Sort descending Modifiers Object type Summary
LayoutBuilderTestThemeHooks::layoutOneCol public function Implements hook_preprocess_HOOK() for one-column layout template.
LayoutBuilderTestThemeHooks::layoutTwocolSection public function Implements hook_preprocess_HOOK() for two-column layout template.
LayoutBuilderTestThemeHooks::theme public function Implements hook_theme().
LayoutBuilderTestThemeHooks::__construct public function

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