function opigno_moxtra_preprocess_views_view_field in Opigno Moxtra 8
Same name and namespace in other branches
- 3.x opigno_moxtra.module \opigno_moxtra_preprocess_views_view_field()
Implements hook_preprocess_views_view_field().
Replaces titles of a live meeting calendar event with links.
File
- ./
opigno_moxtra.module, line 760 - Contains opigno_moxtra.module.
Code
function opigno_moxtra_preprocess_views_view_field(&$vars) {
$id = $vars['view']
->id();
$field = $vars['field']->field;
if ($id === 'opigno_calendar' && $field === 'title') {
/** @var \Drupal\opigno_calendar_event\CalendarEventInterface $entity */
$entity = $vars['row']->_entity;
$bundle = $entity
->bundle();
if ($bundle === 'meeting_calendar_event') {
$title = $vars['field']
->getValue($vars['row']);
/** @var \Drupal\opigno_moxtra\MeetingInterface $meeting */
$meeting = $entity
->get('field_meeting')->entity;
if ($meeting !== NULL) {
$link = Link::createFromRoute($title, 'opigno_moxtra.meeting', [
'opigno_moxtra_meeting' => $meeting
->id(),
]);
$vars['output'] = $link;
}
}
}
}