You are here

public function GoogleNews::attachTo in Views Google News 8

File

src/Plugin/views/style/GoogleNews.php, line 32

Class

GoogleNews
Default style plugin to render an GoogleNews feed.

Namespace

Drupal\views_googlenews\Plugin\views\style

Code

public function attachTo(array &$build, $display_id, $path, $title) {
  $display = $this->view->displayHandlers
    ->get($display_id);
  $url_options = [];
  $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)) {
      $build['#attached']['feed'][] = [
        $url,
        $title,
      ];
    }
  }
  else {
    $this->view->feedIcons[] = [
      '#theme' => 'feed_icon',
      '#url' => $url,
      '#title' => $title,
    ];
  }
}