function DisplayPluginBase::getMoreUrl

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

Get the more URL for this view.

Uses the custom URL if there is one, otherwise the display path.

Return value

\Drupal\Core\Url The more link as Url object.

1 call to DisplayPluginBase::getMoreUrl()
DisplayPluginBase::renderMoreLink in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Renders the 'more' link.

File

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

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

protected function getMoreUrl() {
    $path = $this->getOption('link_url');
    // Return the display URL if there is no custom url.
    if ($this->getOption('link_display') !== 'custom_url' || empty($path)) {
        return $this->view
            ->getUrl(NULL, $this->display['id']);
    }
    $parts = UrlHelper::parse($path);
    $options = $parts;
    $tokens = $this->getArgumentsTokens();
    // If there are no tokens there is nothing else to do.
    if (!empty($tokens)) {
        $parts['path'] = $this->viewsTokenReplace($parts['path'], $tokens);
        $parts['fragment'] = $this->viewsTokenReplace($parts['fragment'], $tokens);
        // Handle query parameters where the key is part of an array.
        // For example, f[0] for facets.
        array_walk_recursive($parts['query'], function (&$value) use ($tokens) {
            $value = $this->viewsTokenReplace($value, $tokens);
        });
        $options = $parts;
    }
    $path = $options['path'];
    unset($options['path']);
    // Create url.
    // @todo Views should expect and store a leading /. See:
    //   https://www.drupal.org/node/2423913
    $url = UrlHelper::isExternal($path) ? Url::fromUri($path, $options) : Url::fromUserInput('/' . ltrim($path, '/'), $options);
    // Merge the exposed query parameters.
    if (!empty($this->view->exposed_raw_input)) {
        $url->mergeOptions([
            'query' => $this->view->exposed_raw_input,
        ]);
    }
    return $url;
}

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