function pager_query_add_page in Drupal 8
Gets the URL query parameter array of a pager link.
Adds to or adjusts the 'page' URL query parameter so that if you follow the link, you'll get page $index for pager $element on the page.
The 'page' URL query parameter is a comma-delimited string, where each value is the target content page for the corresponding pager $element. For instance, if we have 5 pagers on a single page, and we want to have a link to a page that should display the 6th content page for the 3rd pager, and the 1st content page for all the other pagers, then the URL query will look like this: ?page=0,0,5,0,0 (page numbering starts at zero).
Parameters
array $query: An associative array of URL query parameters to add to.
int $element: An integer to distinguish between multiple pagers on one page.
int $index: The index of the target page, for the given element, in the pager array.
Return value
array The altered $query parameter array.
Deprecated
in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Pager\PagerManagerInterface::getUpdatedParameters() instead.
See also
https://www.drupal.org/node/2779457
\Drupal\Core\Pager\PagerManagerInterface::getUpdatedParameters()
1 call to pager_query_add_page()
- PagerDeprecationTest::testQueryAddPage in core/
modules/ system/ tests/ src/ Kernel/ Pager/ PagerDeprecationTest.php - @expectedDeprecation pager_query_add_page is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Pager\PagerManagerInterface->getUpdatedParameters() instead. See https://www.drupal.org/node/2779457
File
- core/
includes/ pager.inc, line 343 - Functions to aid in presenting database results as a set of pages.
Code
function pager_query_add_page(array $query, $element, $index) {
@trigger_error(__FUNCTION__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \\Drupal\\Core\\Pager\\PagerManagerInterface->getUpdatedParameters() instead. See https://www.drupal.org/node/2779457', E_USER_DEPRECATED);
/* @var $pager_manager \Drupal\Core\Pager\PagerManagerInterface */
$pager_manager = \Drupal::service('pager.manager');
return $pager_manager
->getUpdatedParameters($query, $element, $index);
}