You are here

public function IcalWizard::attachTo in Views iCal 8

File

src/Plugin/views/style/IcalWizard.php, line 191

Class

IcalWizard
Style plugin to render an iCal feed. This provides a style usable for Feed displays.

Namespace

Drupal\views_ical\Plugin\views\style

Code

public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
  $url_options = [];
  $input = $this->view
    ->getExposedInput();
  if ($input) {
    $url_options['query'] = $input;
  }
  $url_options['absolute'] = TRUE;
  $url = $feed_url
    ->setOptions($url_options)
    ->toString();
  $this->view->feedIcons[] = [];

  // Attach a link to the iCal feed, which is an alternate representation.
  $build['#attached']['html_head_link'][][] = [
    'rel' => 'alternate',
    'type' => 'application/calendar',
    'href' => $url,
    'title' => $title,
  ];
}