You are here

function views_ical_preprocess_views_view_ical in Views iCal 8

Prepares variables for Views iCal template.

Default template: views-view-ical.html.twig.

Parameters

array $variables: An associative array containing:

  • view: A View object.

File

./views_ical.module, line 15

Code

function views_ical_preprocess_views_view_ical(&$variables) {
  module_load_include('inc', 'views', 'views.theme');
  $view = $variables['view'];
  $view
    ->getResponse()->headers
    ->set('Content-Type', 'text/calendar; charset=utf-8');
  if ($view->display_handler
    ->getOption('sitename_title')) {
    $config = \Drupal::config('system.site');
    $title = $config
      ->get('name');
    if ($slogan = $config
      ->get('slogan')) {
      $title .= ' - ' . $slogan;
    }
  }
  else {
    $title = $view
      ->getTitle();
  }
  $variables['title'] = $title;
  template_preprocess_views_view_unformatted($variables);
}