class TestContextAwareLayout in Drupal 10
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php \Drupal\layout_builder_test\Plugin\Layout\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 = {
"user" = @ContextDefinition("entity:user")
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Layout\LayoutDefault implements LayoutInterface, PluginFormInterface, PreviewAwarePluginInterface uses ContextAwarePluginAssignmentTrait, ContextAwarePluginTrait
- class \Drupal\layout_builder_test\Plugin\Layout\TestContextAwareLayout
- class \Drupal\Core\Layout\LayoutDefault implements LayoutInterface, PluginFormInterface, PreviewAwarePluginInterface uses ContextAwarePluginAssignmentTrait, ContextAwarePluginTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TestContextAwareLayout
File
- core/
modules/ layout_builder/ tests/ modules/ layout_builder_test/ src/ Plugin/ Layout/ TestContextAwareLayout.php, line 21
Namespace
Drupal\layout_builder_test\Plugin\LayoutView source
class TestContextAwareLayout extends LayoutDefault {
/**
* {@inheritdoc}
*/
public function build(array $regions) {
$build = parent::build($regions);
$build['main']['#attributes']['class'][] = 'user--' . $this
->getContextValue('user')
->getAccountName();
return $build;
}
}