You are here

protected function EntityPager::getAllLink in Entity Pager 8

Same name and namespace in other branches
  1. 2.0.x src/EntityPager.php \Drupal\entity_pager\EntityPager::getAllLink()

Returns a Display All link render array.

Return value

array The element to render.

1 call to EntityPager::getAllLink()
EntityPager::getLinks in src/EntityPager.php
Gets an array of entity pager link render arrays.

File

src/EntityPager.php, line 184

Class

EntityPager
Entity pager object.

Namespace

Drupal\entity_pager

Code

protected function getAllLink() {
  $link = [];
  if ($this->options['display_all']) {
    $entity = $this
      ->getEntity();
    $url = $this
      ->detokenize($this->options['link_all_url'], $entity);
    $url_scheme = parse_url($url, PHP_URL_SCHEME);
    if (!$url_scheme) {
      if (!in_array(substr($url, 0, 1), [
        '/',
        '#',
        '?',
      ])) {
        $url = '/' . $url;
      }
      $url = urldecode($url);
    }
    $link = [
      '#type' => 'link',
      '#title' => [
        '#markup' => $this
          ->detokenize($this->options['link_all_text'], $entity),
      ],
      '#url' => $url_scheme ? Url::fromUri($url) : Url::fromUserInput($url),
    ];
  }
  return $link;
}