You are here

public function Ical::attachTo in Views iCal 8

File

src/Plugin/views/style/Ical.php, line 27

Class

Ical
Style plugin to render an iCal feed.

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,
  ];
}