function layout_builder_test_node_view

Same name and namespace in other branches
  1. 8.9.x core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module \layout_builder_test_node_view()
  2. 10 core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module \layout_builder_test_node_view()
  3. 11.x core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module \layout_builder_test_node_view()

Implements hook_entity_node_view().

File

core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module, line 66

Code

function layout_builder_test_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
    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.