TestContextAwareLayout.php in Drupal 9
File
core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php
View source
<?php
namespace Drupal\layout_builder_test\Plugin\Layout;
use Drupal\Core\Layout\LayoutDefault;
class TestContextAwareLayout extends LayoutDefault {
public function build(array $regions) {
$build = parent::build($regions);
$build['main']['#attributes']['class'][] = 'user--' . $this
->getContextValue('user')
->getAccountName();
return $build;
}
}
Classes
Name |
Description |
TestContextAwareLayout |
Plugin annotation
@Layout(
id = "layout_builder_test_context_aware",
label = @Translation("Layout Builder Test: Context Aware"),
regions = {
"main" = {
"label" = @Translation("Main Region")
}
},
context_definitions = {
… |