You are here

public function RssFields::attachTo in Views RSS 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/style/RssFields.php \Drupal\views_rss\Plugin\views\style\RssFields::attachTo()

File

src/Plugin/views/style/RssFields.php, line 61
Definition of Drupal\views\Plugin\views\style\Rss.

Class

RssFields
Default style plugin to render an RSS feed from fields.

Namespace

Drupal\views_rss\Plugin\views\style

Code

public function attachTo(array &$build, $display_id, $path, $title) {
  $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);

  // Add the RSS icon to the view.
  $this->view->feedIcons[] = [
    '#theme' => 'feed_icon',
    '#url' => $url,
    '#title' => $title,
  ];

  // Attach a link to the RSS feed, which is an alternate representation.
  $build['#attached']['html_head_link'][][] = array(
    'rel' => 'alternate',
    'type' => 'application/rss+xml',
    'title' => $title,
    'href' => $url,
  );
}