function DisplayPluginBase::renderMoreLink

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::renderMoreLink()
  2. 10 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::renderMoreLink()
  3. 9 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::renderMoreLink()
  4. 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::renderMoreLink()

Renders the 'more' link.

Overrides DisplayPluginInterface::renderMoreLink

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 2110

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function renderMoreLink() {
  $hasMoreRecords = !empty($this->view->pager) && $this->view->pager
    ->hasMoreRecords();
  if ($this->isMoreEnabled() && ($this->useMoreAlways() || $hasMoreRecords)) {
    $url = $this->getMoreUrl();
    $access = $url->access(return_as_object: TRUE);
    $more_link = [
      '#type' => 'more_link',
      '#url' => $url,
      '#title' => $this->useMoreText(),
      '#view' => $this->view,
      '#access' => $access->isAllowed(),
    ];
    $accessCacheability = CacheableMetadata::createFromObject($access);
    $accessCacheability->applyTo($more_link);
    return $more_link;
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.