You are here

function _cleanpager_url in Clean Pagination 8

Create clean url for pager pager link.

2 calls to _cleanpager_url()
cleanpager_preprocess_pager in ./cleanpager.module
Implements template_preprocess_pager().
cleanpager_preprocess_views_mini_pager in ./cleanpager.module
Implements template_preprocess_views_mini_pager().

File

./cleanpager.module, line 135
Fto Clean Pager module file.

Code

function _cleanpager_url($route_name, $route_parameters, $options) {
  global $_cleanpager_pagination;
  $url = '';
  $uri = \Drupal::request()
    ->getPathInfo();
  if ($_cleanpager_pagination) {
    if ($page_pos = strpos($uri, '/page/')) {
      $q = substr($uri, 0, $page_pos);
    }
    else {
      $q = $uri;
    }
    if (isset($options['query']['page'])) {
      if ($q === '/') {
        $q .= '';
      }
      $url = $q . '/page/' . $options['query']['page'];
      if (\Drupal::configFactory()
        ->get('cleanpager.settings')
        ->get('cleanpager_add_trailing')) {
        $url .= '/';
      }
      unset($options['query']['page']);
    }
  }
  unset($options['query']['q']);
  $url .= \Drupal::url($route_name, $route_parameters, $options);
  return $url;
}