You are here

function opigno_calendar_preprocess_calendar_month_col in Opigno calendar 8

Same name and namespace in other branches
  1. 3.x opigno_calendar.module \opigno_calendar_preprocess_calendar_month_col()

Implements hook_preprocess_HOOK().

File

./opigno_calendar.module, line 42
Contains opigno_calendar.module.

Code

function opigno_calendar_preprocess_calendar_month_col(&$variables) {
  if (empty($variables['item']['entry'])) {
    return;
  }
  $entry =& $variables['item']['entry'];
  if ($variables['item']['date'] === date('Y-m-d')) {
    $variables['item']['entry']['#selected'] = TRUE;
  }
  if (!is_array($entry) || isset($entry['#theme'])) {
    return;
  }
  $attached = [
    'library' => [
      'opigno_calendar/month_block',
    ],
  ];
  if (isset($entry[0]['#theme']) && $entry[0]['#theme'] === 'calendar_empty_day') {
    $entry['#attached'] = $attached;
    return;
  }

  /** @var \Drupal\views\ViewExecutable $view */
  $view = $entry[0]['#view'];
  if (!$view || $view
    ->getDisplay()
    ->getOption('css_class') !== 'opigno-calendar-views' && $view
    ->getDisplay()
    ->getOption('css_class') !== 'view-opigno-calendar' || $view->current_display !== 'month_block' && $view->current_display !== 'page_month') {
    return;
  }
  $entry = opigno_calendar_generate_entry($variables, $entry, $attached);
}