QueryBuilderPaginator extends AbstractPaginator
Provides a paginator implementation to be used with {@see QueryBuilder} as data source.
Be aware that this comes with a couple of things to be considered:
-
QueryBuilder is used in a generic way by this Paginator and does not take care of proper language overlay handling and cannot do that in a easy way and applying overlays on the result set can lead to weired item count jumps on pages in case some of them are removed. For example 5 items on page 1, 6 on page two albeit 10 items per page has been requested.
-
The paginator is completely in charge handling the pagination (offset/limit) and does not take existing constraints of the passed QueryBuilder into account to match the expectation shared across pagination handling throughout different frameworks and other Paginator implementation of TYPO3.
Table of Contents
Properties
- $keyOfFirstPaginatedItem : int
- $keyOfLastPaginatedItem : int
- $numberOfPages : int
Methods
- __construct() : mixed
- getCurrentPageNumber() : int
- Returns the current page number
- getKeyOfFirstPaginatedItem() : int
- Returns the key of the first paginated item
- getKeyOfLastPaginatedItem() : int
- Returns the key of the last paginated item
- getNumberOfPages() : int
- Returns the total number of pages, given the total number of non paginated items and the items per page configuration
- getPaginatedItems() : iterable<string|int, mixed>
- Returns an iterable, sub set of the original set of items
- withCurrentPageNumber() : PaginatorInterface
- Sets the current page to calculate paginated items for
- withItemsPerPage() : PaginatorInterface
- Sets the amount of paginated items per page
- getAmountOfItemsOnCurrentPage() : int
- Must return the amount of paginated items on the current page
- getTotalAmountOfItems() : int
- Must return the total amount of all unpaginated items
- hasItemsOnCurrentPage() : bool
- States whether there are items on the current page
- setCurrentPageNumber() : void
- setItemsPerPage() : void
- updateInternalState() : void
- This method is the heart of the pagination. It updates all internal params and then calls the {@see updatePaginatedItems} method which must update the set of paginated items.
- updatePaginatedItems() : void
- Must update the paginated items, i.e. the subset of all items, limited and defined by the given amount of items per page and offset
Properties
$keyOfFirstPaginatedItem
protected
int
$keyOfFirstPaginatedItem
= 0
$keyOfLastPaginatedItem
protected
int
$keyOfLastPaginatedItem
= 0
$numberOfPages
protected
int
$numberOfPages
= 1
Methods
__construct()
public
__construct(QueryBuilder $queryBuilder[, int $currentPageNumber = 1 ][, int $itemsPerPage = 10 ]) : mixed
Parameters
- $queryBuilder : QueryBuilder
- $currentPageNumber : int = 1
- $itemsPerPage : int = 10
getCurrentPageNumber()
Returns the current page number
public
getCurrentPageNumber() : int
Return values
intgetKeyOfFirstPaginatedItem()
Returns the key of the first paginated item
public
getKeyOfFirstPaginatedItem() : int
This is useful to display the exact range of items that are available via getPaginatedItems
Return values
intgetKeyOfLastPaginatedItem()
Returns the key of the last paginated item
public
getKeyOfLastPaginatedItem() : int
This is useful to display the exact range of items that are available via getPaginatedItems
Return values
intgetNumberOfPages()
Returns the total number of pages, given the total number of non paginated items and the items per page configuration
public
getNumberOfPages() : int
Return values
intgetPaginatedItems()
Returns an iterable, sub set of the original set of items
public
getPaginatedItems() : iterable<string|int, mixed>
Return values
iterable<string|int, mixed>withCurrentPageNumber()
Sets the current page to calculate paginated items for
public
withCurrentPageNumber(int $currentPageNumber) : PaginatorInterface
Must return a new instance of the Paginator with an updated internal state
Parameters
- $currentPageNumber : int
Return values
PaginatorInterfacewithItemsPerPage()
Sets the amount of paginated items per page
public
withItemsPerPage(int $itemsPerPage) : PaginatorInterface
Must return a new instance of the Paginator with an updated internal state
Parameters
- $itemsPerPage : int
Return values
PaginatorInterfacegetAmountOfItemsOnCurrentPage()
Must return the amount of paginated items on the current page
protected
getAmountOfItemsOnCurrentPage() : int
Return values
intgetTotalAmountOfItems()
Must return the total amount of all unpaginated items
protected
getTotalAmountOfItems() : int
Return values
inthasItemsOnCurrentPage()
States whether there are items on the current page
protected
hasItemsOnCurrentPage() : bool
Return values
boolsetCurrentPageNumber()
protected
setCurrentPageNumber(int $currentPageNumber) : void
Parameters
- $currentPageNumber : int
setItemsPerPage()
protected
setItemsPerPage(int $itemsPerPage) : void
Parameters
- $itemsPerPage : int
updateInternalState()
This method is the heart of the pagination. It updates all internal params and then calls the {@see updatePaginatedItems} method which must update the set of paginated items.
protected
updateInternalState() : void
updatePaginatedItems()
Must update the paginated items, i.e. the subset of all items, limited and defined by the given amount of items per page and offset
protected
updatePaginatedItems(int $itemsPerPage, int $offset) : void
Parameters
- $itemsPerPage : int
- $offset : int