PaginationService
class PaginationService (View source)
Builds Pagination objects and resolves the rows-per-page value within the allowed bounds.
Constants
| MIN_ROWS_PER_PAGE |
|
| MAX_ROWS_PER_PAGE |
|
| ROWS_PER_PAGE_PRESETS |
Offered in the page-size dropdowns; any value within the bounds is still honoured. |
| DEFAULT_ROWS_PER_PAGE |
|
Methods
Create a pagination object with proper validation
Resolves the page size: the value the request asked for wins and is stored as the user's preference, otherwise the stored preference, otherwise the configured default.
A submitted page size, when it is a number inside the supported range; any value in range is accepted, not only the presets.
Sliding window of up to nine page links centred on the current page, with break indicators when the window does not touch the first or last page.
Page sizes to offer, so the current and configured values are always selectable.
Details
__construct(UserPreferenceService|null $userPreferenceService = null)
No description
Pagination
createPagination(int $totalItems, int $itemsPerPage, int $currentPage)
Create a pagination object with proper validation
int
getUserRowsPerPage(int $defaultRowsPerPage, int|null $userId, int|null $requestedRowsPerPage)
Resolves the page size: the value the request asked for wins and is stored as the user's preference, otherwise the stored preference, otherwise the configured default.
static int|null
acceptedRowsPerPage(mixed $submitted)
A submitted page size, when it is a number inside the supported range; any value in range is accepted, not only the presets.
static array
pagerWindow(int $total, int $rowAmount, int $currentPage)
Sliding window of up to nine page links centred on the current page, with break indicators when the window does not touch the first or last page.
Deliberately not the Pagination model: that one shifts the window left near the last page, which would change what the search pager renders.
array
getRowsPerPageOptions(int ...$extra)
Page sizes to offer, so the current and configured values are always selectable.