PagerManagerInterface
interface PagerManagerInterface (View source)
This is a service for pager information.
The pager.manager service manages the pager information which will eventually be rendered into pager elements in the response. To gather information related to pager information in the request, use the pager.parameters service.
Since there can be multiple pagers per requested page, each one is represented by an 'element' ID. This is an integer. It represents the index of the pager element within the 'page' query. The value of the element is an integer telling us the current page number for that pager.
Methods
Initializes a pager.
Returns the current page being requested for display within a pager.
Gets the URL query parameter array of a pager link.
Gets the extent of the pager page element IDs.
Reserve a pager element ID.
Details
Pager
createPager(int $total, int $limit, int $element = 0)
Initializes a pager.
This function sets up the necessary variables so that the render system will correctly process #type 'pager' render arrays to output pagers that correspond to the items being displayed.
If the items being displayed result from a database query performed using Drupal's database API, and if you have control over the construction of the database query, you do not need to call this function directly; instead, you can extend the query object with the 'PagerSelectExtender' extender before executing it. For example:
Pager|null
getPager(int $element = 0)
Gets a pager from the static cache.
int
findPage(int $pager_id = 0)
Returns the current page being requested for display within a pager.
array
getUpdatedParameters(array $query, int $element, int $index)
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).
int
getMaxPagerElementId()
Gets the extent of the pager page element IDs.
void
reservePagerElementId(int $element)
Reserve a pager element ID.
Calling code may need to reserve the ID of a pager before actually creating it. This methods allows to do so ensuring no collision occurs with ::getMaxPagerElementId().