You are here

public function PlainText::attachTo in Recipe 8.2

File

src/Plugin/views/style/PlainText.php, line 42

Class

PlainText
Default style plugin to render recipes in plain text.

Namespace

Drupal\recipe\Plugin\views\style

Code

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

  // Attach a link to the plain text, which is an alternate representation.
  $build['#attached']['html_head_link'][][] = [
    'rel' => 'alternate',
    'type' => 'text/plain',
    'title' => $title,
    'href' => $url
      ->setOptions($url_options)
      ->toString(),
  ];
}