class PagerParameters in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Pager/PagerParameters.php \Drupal\Core\Pager\PagerParameters
- 9 core/lib/Drupal/Core/Pager/PagerParameters.php \Drupal\Core\Pager\PagerParameters
Provides pager information contained within the current request.
Hierarchy
- class \Drupal\Core\Pager\PagerParameters implements \Drupal\Core\Pager\PagerParametersInterface
Expanded class hierarchy of PagerParameters
See also
\Drupal\Core\Pager\PagerManagerInterface
1 string reference to 'PagerParameters'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses PagerParameters
File
- core/
lib/ Drupal/ Core/ Pager/ PagerParameters.php, line 13
Namespace
Drupal\Core\PagerView source
class PagerParameters implements PagerParametersInterface {
/**
* The HTTP request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* Construct a PagerManager object.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $stack
* The current HTTP request stack.
*/
public function __construct(RequestStack $stack) {
$this->requestStack = $stack;
}
/**
* {@inheritdoc}
*/
public function getQueryParameters() {
$request = $this->requestStack
->getCurrentRequest();
if ($request) {
return UrlHelper::filterQueryParameters($request->query
->all(), [
'page',
]);
}
return [];
}
/**
* {@inheritdoc}
*/
public function findPage($pager_id = 0) {
$pages = $this
->getPagerQuery();
return (int) ($pages[$pager_id] ?? 0);
}
/**
* {@inheritdoc}
*/
public function getPagerQuery() {
$query = $this
->getPagerParameter();
return !empty($query) ? explode(',', $query) : [];
}
/**
* {@inheritdoc}
*/
public function getPagerParameter() {
$request = $this->requestStack
->getCurrentRequest();
if ($request) {
return $request->query
->get('page', '');
}
return '';
}
}