You are here

public function CleanPagerSubscriber::cleanPagerHttpBuildQuery in Clean Pagination 8

1 call to CleanPagerSubscriber::cleanPagerHttpBuildQuery()
CleanPagerSubscriber::checkForRedirection in src/EventSubscriber/CleanPagerSubscriber.php

File

src/EventSubscriber/CleanPagerSubscriber.php, line 60
Fto redirects.

Class

CleanPagerSubscriber

Namespace

Drupal\cleanpager\EventSubscriber

Code

public function cleanPagerHttpBuildQuery(array $query, $parent = '') {
  $params = array();
  foreach ($query as $key => $value) {
    $key = $parent ? $parent . '[' . rawurlencode($key) . ']' : rawurlencode($key);

    // Recurse into children.
    if (is_array($value)) {
      $params[] = $this
        ->cleanPagerHttpBuildQuery($value, $key);
    }
    elseif (!isset($value)) {
      $params[] = $key;
    }
    else {

      // For better readability of paths in query strings, we decode slashes.
      $params[] = $key . '=' . str_replace('%2F', '/', rawurlencode($value));
    }
  }
  return implode('&', $params);
}