function LayoutBuilderTestEntityHooks::nodeView
Implements hook_ENTITY_TYPE_view().
Attributes
#[Hook('node_view')]
File
-
core/
modules/ layout_builder/ tests/ modules/ layout_builder_test/ src/ Hook/ LayoutBuilderTestEntityHooks.php, line 20
Class
- LayoutBuilderTestEntityHooks
- Entity hook implementations for layout_builder_test.
Namespace
Drupal\layout_builder_test\HookCode
public function nodeView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) : void {
if ($display->getComponent('layout_builder_test')) {
$build['layout_builder_test'] = [
'#markup' => 'Extra, Extra read all about it.',
];
}
if ($display->getComponent('layout_builder_test_2')) {
$build['layout_builder_test_2'] = [
'#markup' => 'Extra Field 2 is hidden by default.',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.