public function CleanPager::handle in Clean Pagination 8
File
- src/
StackMiddleware/ CleanPager.php, line 82
Class
- CleanPager
- Provides a HTTP middleware.
Namespace
Drupal\cleanpager\StackMiddlewareCode
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
global $_cleanpager_pagination;
$path = $this
->cleanPagerGetQ($request);
if ($path_length = strpos($path, '/page/')) {
$path_test_part = substr($path, 0, $path_length);
}
else {
$path_test_part = $path;
}
$pages = \Drupal::configFactory()
->get('cleanpager.settings')
->get('cleanpager_pages');
if (\Drupal::service('path.matcher')
->matchPath($path_test_part, $pages)) {
$_cleanpager_pagination = TRUE;
$result = $this
->rewriteUrl($request, $path);
}
else {
$_cleanpager_pagination = FALSE;
$result = $request;
}
return $this->httpKernel
->handle($result, $type, $catch);
}