You are here

function availability_calendar_process_availability_calendar_ical in Availability Calendars 7.5

Implements hook_process_HOOK for theme availability_calendar_ical.

On entry, $variables contains:

  • entity_type
  • entity
  • settings (field settings)
  • langcode
  • cid
  • name

On exit it should also contain:

  • from
  • to
  • events

Parameters

array $variables:

Throws

\Exception

File

./availability_calendar.ical.inc, line 28

Code

function availability_calendar_process_availability_calendar_ical(&$variables) {
  if (empty($variables['events'])) {
    if (empty($variables['from'])) {
      $variables['from'] = (new DateTime())
        ->setTime(0, 0, 0);
    }
    if (empty($variables['to'])) {
      $months_to_render = !empty($variables['settings']['show_number_of_months']) ? $variables['settings']['show_number_of_months'] : 12;
      $to = clone $variables['from'];
      $to
        ->add(new DateInterval("P{$months_to_render}M"));
      $to
        ->sub(new DateInterval('P1D'));
      $variables['to'] = $to;
    }
    $variables['events'] = availability_calendar_get_unavailable_periods((int) $variables['cid'], $variables['from'], $variables['to'], $variables['settings']['default_state']);
  }
}