function forward_entity_view in Forward 8.2
Same name and namespace in other branches
- 8.3 forward.module \forward_entity_view()
- 8 forward.module \forward_entity_view()
- 7.3 forward.module \forward_entity_view()
Implements hook_entity_view().
File
- ./
forward.module, line 76 - Allows forwarding of entities by email.
Code
function forward_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
$settings = \Drupal::config('forward.settings')
->get();
// Let hook_node_links_alter handle Forward inline links on nodes.
if ($settings['forward_link_inline'] && $settings['forward_interface_type'] == 'link' && $entity
->getEntityTypeId() == 'node') {
return;
}
// Display a forward link or form unless the entity is being rendered
// for a forward email or by layout builder. When using layout builder,
// the Forward block (Link or Form) is placed directly into the layout.
$show = \Drupal::service('forward.access_checker')
->isAllowed($settings, $entity, $view_mode) && empty($build['#forward_build']) && empty($build['_layout_builder']);
if ($show) {
if ($settings['forward_interface_type'] == 'link') {
$build['forward'] = \Drupal::service('forward.link_builder')
->buildForwardEntityLink($entity, $settings);
}
else {
$build['forward'] = \Drupal::service('forward.form_builder')
->buildForwardEntityForm($entity, $settings);
}
}
}