You are here

function pager_find_page in Drupal 8

Same name and namespace in other branches
  1. 7 includes/pager.inc \pager_find_page()

Returns the current page being requested for display within a pager.

Parameters

int $element: (optional) An integer to distinguish between multiple pagers on one page.

Return value

int The number of the current requested page, within the pager represented by $element. This is determined from the URL query parameter \Drupal::request()->query->get('page'), or 0 by default. Note that this number may differ from the actual page being displayed. For example, if a search for "example text" brings up three pages of results, but a user visits search/node/example+text?page=10, this function will return 10, even though the default pager implementation adjusts for this and still displays the third page of search results at that URL.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Pager\PagerParametersInterface->findPage() instead.

See also

https://www.drupal.org/node/2779457

\Drupal\Core\Pager\PagerParametersInterface::findPage()

1 call to pager_find_page()
PagerDeprecationTest::testFindPage in core/modules/system/tests/src/Kernel/Pager/PagerDeprecationTest.php
@expectedDeprecation pager_find_page is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Pager\PagerParametersInterface->findPage() instead. See https://www.drupal.org/node/2779457

File

core/includes/pager.inc, line 34
Functions to aid in presenting database results as a set of pages.

Code

function pager_find_page($element = 0) {
  @trigger_error(__FUNCTION__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \\Drupal\\Core\\Pager\\PagerParametersInterface->findPage() instead. See https://www.drupal.org/node/2779457', E_USER_DEPRECATED);

  /* @var $pager_parameters \Drupal\Core\Pager\PagerParametersInterface */
  $pager_parameters = \Drupal::service('pager.parameters');
  return $pager_parameters
    ->findPage($element);
}