LayoutBuilderTestThemeHooks.php
Namespace
Drupal\layout_builder_test\HookFile
-
core/
modules/ layout_builder/ tests/ modules/ layout_builder_test/ src/ Hook/ LayoutBuilderTestThemeHooks.php
View source
<?php
declare (strict_types=1);
namespace Drupal\layout_builder_test\Hook;
use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Component\Uuid\UuidInterface;
/**
* Theme hook implementations for layout_builder_test.
*/
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()),
];
}
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
LayoutBuilderTestThemeHooks | Theme hook implementations for layout_builder_test. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.