Interface Yiisoft\Data\Paginator\PaginatorInterface
| Extends | Yiisoft\Data\Reader\ReadableDataInterface |
|---|---|
| Implemented by | Yiisoft\Data\Paginator\KeysetPaginator, Yiisoft\Data\Paginator\OffsetPaginator |
Paginator interface defines a common pagination methods shared by all pagination types.
- Each page has string "tokens" for getting to the previous and next page.
- Maximum number of items per page could be set.
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| DEFAULT_PAGE_SIZE | 10 | Page size that is used in case it is not set explicitly. | Yiisoft\Data\Paginator\PaginatorInterface |
Method Details
Get number of items at the current page.
Note that it is an actual number of items, not the limit.
See also getPageSize().
| public abstract integer getCurrentPageSize ( ) | ||
| return | integer |
Current page size. |
|---|---|---|
public function getCurrentPageSize(): int;
Returns data reader filter.
| public abstract Yiisoft\Data\Reader\FilterInterface getFilter ( ) | ||
| return | Yiisoft\Data\Reader\FilterInterface |
Data reader filter. |
|---|---|---|
| throws | LogicException |
When data reader doesn't support filter. |
public function getFilter(): FilterInterface;
Get token for the next page.
| public abstract Yiisoft\Data\Paginator\PageToken|null getNextToken ( ) | ||
| return | Yiisoft\Data\Paginator\PageToken|null |
Page token for the next page. |
|---|---|---|
public function getNextToken(): ?PageToken;
Get the maximum number of items per page.
Note that there could be less current page items.
See also getCurrentPageSize().
| public abstract integer getPageSize ( ) | ||
| return | integer |
Page size. |
|---|---|---|
public function getPageSize(): int;
Get token for the previous page.
| public abstract Yiisoft\Data\Paginator\PageToken|null getPreviousToken ( ) | ||
| return | Yiisoft\Data\Paginator\PageToken|null |
Page token for the previous page. |
|---|---|---|
public function getPreviousToken(): ?PageToken;
Get current sort object.
| public abstract Yiisoft\Data\Reader\Sort|null getSort ( ) | ||
| return | Yiisoft\Data\Reader\Sort|null |
Current sort object or null if no sorting is used. |
|---|---|---|
public function getSort(): ?Sort;
| public abstract Yiisoft\Data\Paginator\PageToken|null getToken ( ) | ||
| return | Yiisoft\Data\Paginator\PageToken|null |
Current page token or |
|---|---|---|
public function getToken(): ?PageToken;
| public abstract boolean isFilterable ( ) | ||
| return | boolean |
Whether data reader does support filtering. |
|---|---|---|
public function isFilterable(): bool;
Get whether the current page is the first one.
| public abstract boolean isOnFirstPage ( ) | ||
| return | boolean |
Whether the current page is the first one. |
|---|---|---|
public function isOnFirstPage(): bool;
Get whether the current page is the last one.
| public abstract boolean isOnLastPage ( ) | ||
| return | boolean |
Whether the current page is the last one. |
|---|---|---|
public function isOnLastPage(): bool;
Check that there is more than a single page so pagination is necessary.
| public abstract boolean isPaginationRequired ( ) | ||
| return | boolean |
Whether pagination is required. |
|---|---|---|
public function isPaginationRequired(): bool;
| public abstract boolean isSortable ( ) | ||
| return | boolean |
Whether changing sorting via {@see \Yiisoft\Data\Paginator\withSorting()} is supported. |
|---|---|---|
public function isSortable(): bool;
Get a data reader for the next page.
| public abstract Yiisoft\Data\Paginator\PaginatorInterface|null nextPage ( ) | ||
| return | Yiisoft\Data\Paginator\PaginatorInterface|null |
Data reader for the next page or |
|---|---|---|
public function nextPage(): ?static;
Get a data reader for the next page.
| public abstract Yiisoft\Data\Paginator\PaginatorInterface|null previousPage ( ) | ||
| return | Yiisoft\Data\Paginator\PaginatorInterface|null |
Data reader for the next page or |
|---|---|---|
public function previousPage(): ?static;
Get an iterator that could be used to read currently active page items.
| public abstract iterable read ( ) | ||
| return | iterable |
Iterator with items for the current page. |
|---|---|---|
| throws | Yiisoft\Data\Paginator\PageNotFoundException |
If the page specified isn't found. |
public function read(): iterable;
Defined in: Yiisoft\Data\Reader\ReadableDataInterface::readOne()
Get one item from the data set. Which item is returned is up to implementation.
Note that invoking this method doesn't impact the data set or its pointer.
| public abstract array|object|null readOne ( ) | ||
| return | array|object|null |
An item or null if there is none. |
|---|---|---|
public function readOne(): array|object|null;
Returns new instance with data reading criteria set.
| public abstract Yiisoft\Data\Paginator\PaginatorInterface withFilter ( Yiisoft\Data\Reader\FilterInterface $filter ) | ||
| $filter | Yiisoft\Data\Reader\FilterInterface |
Data reading criteria. |
| return | Yiisoft\Data\Paginator\PaginatorInterface |
New instance. |
|---|---|---|
| throws | LogicException |
When data reader doesn't support filter. |
public function withFilter(FilterInterface $filter): static;
Get a new instance with a page size set.
| public abstract Yiisoft\Data\Paginator\PaginatorInterface withPageSize ( integer $pageSize ) | ||
| $pageSize | integer |
Maximum number of items per page. |
| return | Yiisoft\Data\Paginator\PaginatorInterface |
New instance. |
|---|---|---|
| throws | InvalidArgumentException |
If page size is not a positive number. |
public function withPageSize(int $pageSize): static;
Get a new instance with a sorting set.
| public abstract Yiisoft\Data\Paginator\PaginatorInterface withSort ( Yiisoft\Data\Reader\Sort|null $sort ) | ||
| $sort | Yiisoft\Data\Reader\Sort|null |
Sorting criteria or null for no sorting. |
| return | Yiisoft\Data\Paginator\PaginatorInterface |
New instance. |
|---|---|---|
| throws | LogicException |
When changing sorting isn't supported. |
public function withSort(?Sort $sort): static;
Get a new instance with page token.
See also Yiisoft\Data\Paginator\PageToken.
| public abstract Yiisoft\Data\Paginator\PaginatorInterface withToken ( Yiisoft\Data\Paginator\PageToken|null $token ) | ||
| $token | Yiisoft\Data\Paginator\PageToken|null |
Page token. |
| return | Yiisoft\Data\Paginator\PaginatorInterface |
New instance. |
|---|---|---|
| throws | Yiisoft\Data\Paginator\InvalidPageException |
If page token is incorrect. |
public function withToken(?PageToken $token): static;
Signup or Login in order to comment.