function field_group_entity_view_alter in Field Group 8.3
Same name and namespace in other branches
- 8 field_group.module \field_group_entity_view_alter()
Implements hook_entity_view_alter().
File
- ./
field_group.module, line 342 - Allows administrators to attach field groups.
Code
function field_group_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInterface $display) {
$context = [
'entity_type' => $display
->getTargetEntityTypeId(),
'bundle' => $entity
->bundle(),
'entity' => $entity,
'display_context' => 'view',
'mode' => $display
->getMode(),
];
field_group_attach_groups($build, $context);
// If no theme hook, we have no theme hook to preprocess.
// Add a prerender.
if (empty($build['#theme'])) {
$ds_enabled = FALSE;
if (Drupal::moduleHandler()
->moduleExists('ds')) {
// Check if DS is enabled for this display.
if ($display
->getThirdPartySetting('ds', 'layout') && !Ds::isDisabled()) {
$ds_enabled = TRUE;
}
}
// If DS is enabled, no pre render is needed (DS adds fieldgroup preprocessing).
if (!$ds_enabled) {
$build['#pre_render'][] = [
FormatterHelper::class,
'entityViewPrender',
];
}
}
}