function field_group_entity_view_alter in Field Group 8
Same name and namespace in other branches
- 8.3 field_group.module \field_group_entity_view_alter()
Implements hook_entity_view_alter().
File
- ./
field_group.module, line 221 - Allows administrators to attach custom fields to fieldable types.
Code
function field_group_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInterface $display) {
$context = array(
'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') && !Drupal\ds\Ds::isDisabled()) {
$ds_enabled = true;
}
}
// If DS is enabled, no pre render is needed (DS adds fieldgroup preprocessing).
if (!$ds_enabled) {
$build['#pre_render'][] = 'field_group_entity_view_pre_render';
}
}
}