You are here

public function RecipeML::attachTo in Recipe 8.2

File

src/Plugin/views/style/RecipeML.php, line 61
Copyright (c) FormatData. All rights reserved.

Class

RecipeML
Default style plugin to render RecipeML.

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 RecipeML, which is an alternate representation.
  $build['#attached']['html_head_link'][][] = [
    'rel' => 'alternate',
    'type' => 'text/xml',
    'title' => $title,
    'href' => $url
      ->setOptions($url_options)
      ->toString(),
  ];
}