function paragraphs_test_paragraph_view in Paragraphs 8
Implements hook_ENTITY_TYPE_view().
File
- tests/
modules/ paragraphs_test/ paragraphs_test.module, line 35 - Test module for testing the paragraphs module.
Code
function paragraphs_test_paragraph_view(array &$build, ParagraphInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if (!\Drupal::state('paragraphs_test_parent')) {
return;
}
$parent_type = $entity
->get('parent_type')->value;
$parent_id = $entity
->get('parent_id')->value;
$parent_field_name = $entity
->get('parent_field_name')->value;
\Drupal::messenger()
->addStatus("Parent: {$parent_type}/{$parent_id}/{$parent_field_name}", TRUE);
}