function opigno_calendar_event_entity_view in Opigno calendar event 8
Same name and namespace in other branches
- 3.x opigno_calendar_event.module \opigno_calendar_event_entity_view()
Implements hook_entity_view().
File
- ./
opigno_calendar_event.module, line 157 - Main file for the "Calendar event" module.
Code
function opigno_calendar_event_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($entity instanceof ContentEntityInterface && $display
->getComponent(CalendarEventEmbeddedDisplay::ELEMENT_NAME)) {
$calendar_event_manager = CalendarEventManager::get();
$calendar_events = $calendar_event_manager
->getReferencingCalendarEvents($entity);
if ($calendar_events) {
$field_definition = $calendar_event_manager
->getReferencingFieldDefinition($entity
->getEntityTypeId(), $entity
->bundle());
$build += $calendar_event_manager
->getEmbeddedDisplay()
->build($field_definition, $calendar_events);
}
}
}