You are here

function template_preprocess_calendar_item in Calendar 8

Same name and namespace in other branches
  1. 7.3 theme/theme.inc \template_preprocess_calendar_item()

Implementation of hook_preprocess_calendar_item().

File

./calendar.theme.inc, line 569
Theme functions for the Calendar module.

Code

function template_preprocess_calendar_item(&$vars) {

  // At the last possible minute we fix the values in rendered_fields so it
  // contains the correct rendered content for the type of item and item display.

  /** @var \Drupal\calendar\CalendarEvent $item */
  $item = $vars['item'];
  $multiday_hidden = !empty($vars['view']->style_options['multiday_hidden']) ? $vars['view']->style_options['multiday_hidden'] : [];
  if (!empty($item
    ->getRenderedFields()) && empty($item
    ->getIsMultiDay())) {
    $vars['rendered_fields'] = [
      $item
        ->getRenderedFields(),
    ];
  }
  foreach ($vars['view']->field as $id => $field) {
    if ($field->options['exclude'] || !empty($item
      ->getIsMultiDay()) && in_array($id, $multiday_hidden)) {
      unset($vars['rendered_fields'][0][$id]);
    }
  }
}