public function Rss::attachTo

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php, line 35
Definition of Drupal\views\Plugin\views\style\Rss.

Class

Rss
Default style plugin to render an RSS feed.

Namespace

Drupal\views\Plugin\views\style

Code

public function attachTo($display_id, $path, $title) {
  $display = $this->view->displayHandlers
    ->get($display_id);
  $url_options = array();
  $input = $this->view
    ->getExposedInput();
  if ($input) {
    $url_options['query'] = $input;
  }
  $url_options['absolute'] = TRUE;
  $url = url($this->view
    ->getUrl(NULL, $path), $url_options);
  if ($display
    ->hasPath()) {
    if (empty($this->preview)) {
      drupal_add_feed($url, $title);
    }
  }
  else {
    if (empty($this->view->feed_icon)) {
      $this->view->feed_icon = '';
    }
    $feed_icon = array(
      '#theme' => 'feed_icon',
      '#url' => $url,
      '#title' => $title,
    );
    $this->view->feed_icon .= drupal_render($feed_icon);
    drupal_add_html_head_link(array(
      'rel' => 'alternate',
      'type' => 'application/rss+xml',
      'title' => $title,
      'href' => $url,
    ));
  }
}