public function Pagerer::getQueryParameters in Pagerer 8
Gets the query parameters array of a pager link.
Parameters
array $parameters: An associative array of query string parameters to append to the pager links.
int $page: The target page.
string $adaptive_keys: The adaptive keys string, in the format 'L.R.X', where L is the adaptive lock to left page, R is the adaptive lock to right page, and X is the adaptive center lock for calculation of neighborhood.
Return value
array The updated array of query parameters.
Overrides PagererInterface::getQueryParameters
1 call to Pagerer::getQueryParameters()
- Pagerer::getHref in src/
Pagerer.php - Gets a pager link.
File
- src/
Pagerer.php, line 221
Class
- Pagerer
- Pagerer pager management class.
Namespace
Drupal\pagererCode
public function getQueryParameters(array $parameters, $page, $adaptive_keys = NULL) {
// Build the 'page' and 'page_ak' query parameter elements.
// This is built based on the current page of each pager element (or NULL
// if the pager is not set), with the exception of the requested page index
// for the current element.
$page_el = [];
$page_ak = [];
foreach ($this->factory
->all() as $i => $p) {
$page_el[$i] = $i == $this
->getElement() ? $page : $p
->getCurrentPage();
$page_ak[$i] = $i == $this
->getElement() ? $adaptive_keys : $p
->getAdaptiveKeys();
}
// Build the 'page' and 'page_ak' fragments, removing unneeded trailing
// keys.
while (end($page_el) === NULL) {
array_pop($page_el);
}
$parameters['page'] = implode(',', $page_el);
while (end($page_ak) === NULL) {
array_pop($page_ak);
}
$parameters['page_ak'] = implode(',', $page_ak);
// Merge the updated pager query parameters, with any parameters coming
// from the current request. In case of collision, current parameters
// take precedence over the request ones.
if ($current_request_query = $this
->getCurrentRequest()->query
->all()) {
$parameters = array_merge($current_request_query, $parameters);
}
// Explicitly remove the segments if not relevant.
if (empty($page_el)) {
unset($parameters['page']);
}
if (empty($page_ak)) {
unset($parameters['page_ak']);
}
return $parameters;
}