function BlockContentThemeSuggestionsTestHooks::nodeView
Implements hook_node_view().
File
-
core/
modules/ block_content/ tests/ modules/ block_content_theme_suggestions_test/ src/ Hook/ BlockContentThemeSuggestionsTestHooks.php, line 36
Class
- BlockContentThemeSuggestionsTestHooks
- Hook implementations for block_content_theme_suggestions_test.
Namespace
Drupal\block_content_theme_suggestions_test\HookCode
public function nodeView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, string $view_mode) : void {
// Provide content for the extra field in the form of a content block.
if ($display->getComponent('block_content_extra_field_test')) {
$entity_type_manager = \Drupal::entityTypeManager();
// Load a block content entity with a known UUID created by test setup.
// @see \Drupal\Tests\block_content\Functional\BlockContentThemeSuggestionsTest::setUp()
$block_content = $entity_type_manager->getStorage('block_content')
->loadByProperties([
'uuid' => 'b22c881a-bcfd-4d0c-a41d-3573327705df',
]);
$block_content = reset($block_content);
$build['block_content_extra_field_test'] = $entity_type_manager->getViewBuilder('block_content')
->view($block_content);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.