You are here

protected function Link::renderUrl in Views link area 8

Takes an input \Drupal\Core\Url object and outputs it as needed.

Parameters

\Drupal\Core\Url $url: Standard Drupal URL object.

Return value

array Render array containing the content of this area.

1 call to Link::renderUrl()
Link::render in src/Plugin/views/area/Link.php
Render the area.

File

src/Plugin/views/area/Link.php, line 417

Class

Link
Views area Link handler.

Namespace

Drupal\views_linkarea\Plugin\views\area

Code

protected function renderUrl(Url $url) {
  $options = $url
    ->getOptions();
  $url
    ->setOptions($options);
  if ($this
    ->checkUrlAccess($url) == FALSE) {
    return [
      '#markup' => $this
        ->sanitizeValue($this
        ->tokenizeValue($this->options['access_denied_text'])),
    ];
  }
  $link_text = $this
    ->tokenizeValue($this->options['link_text']);
  $link = [
    '#type' => 'link',
    '#url' => $url,
    '#title' => strip_tags(Html::decodeEntities($link_text)),
  ];
  if (($prefix = $this->options['prefix']) !== '') {
    $link['#prefix'] = $this
      ->tokenizeValue($prefix);
  }
  if (($suffix = $this->options['suffix']) !== '') {
    $link['#suffix'] = $this
      ->tokenizeValue($suffix);
  }
  if ($this->options['output_as_action']) {
    $link = $this
      ->outputAsActionLink($link);
  }
  if ($this->options['rewrite_output'] !== '') {
    $rewritten_output = $this
      ->viewsTokenReplace($this->options['rewrite_output'], [
      'views_linkarea' => $link,
    ]);
    return [
      '#markup' => $this
        ->sanitizeValue($this
        ->tokenizeValue($rewritten_output), 'xss_admin'),
    ];
  }
  return $link;
}