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 getCurrentPageSize( ): integer | ||
| return | integer |
Current page size. |
|---|---|---|
public function getCurrentPageSize(): int;
Returns data reader filter.
| public abstract getFilter( ): Yiisoft\Data\Reader\FilterInterface | ||
| 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 getNextToken( ): Yiisoft\Data\Paginator\PageToken|null | ||
| 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 getPageSize( ): integer | ||
| return | integer |
Page size. |
|---|---|---|
public function getPageSize(): int;
Get token for the previous page.
| public abstract getPreviousToken( ): Yiisoft\Data\Paginator\PageToken|null | ||
| return | Yiisoft\Data\Paginator\PageToken|null |
Page token for the previous page. |
|---|---|---|
public function getPreviousToken(): ?PageToken;
Get current sort object.
| public abstract getSort( ): Yiisoft\Data\Reader\Sort|null | ||
| return | Yiisoft\Data\Reader\Sort|null |
Current sort object or null if no sorting is used. |
|---|---|---|
public function getSort(): ?Sort;
| public abstract getToken( ): Yiisoft\Data\Paginator\PageToken|null | ||
| return | Yiisoft\Data\Paginator\PageToken|null |
Current page token or |
|---|---|---|
public function getToken(): ?PageToken;
| public abstract isFilterable( ): boolean | ||
| return | boolean |
Whether data reader does support filtering. |
|---|---|---|
public function isFilterable(): bool;
Get whether the current page is the first one.
| public abstract isOnFirstPage( ): boolean | ||
| 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 isOnLastPage( ): boolean | ||
| 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 isPaginationRequired( ): boolean | ||
| return | boolean |
Whether pagination is required. |
|---|---|---|
public function isPaginationRequired(): bool;
| public abstract isSortable( ): boolean | ||
| return | boolean |
Whether changing sorting via \Yiisoft\Data\Paginator\withSorting() is supported. |
|---|---|---|
public function isSortable(): bool;
Get a data reader for the next page.
| public abstract nextPage( ): Yiisoft\Data\Paginator\PaginatorInterface|null | ||
| 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 previousPage( ): Yiisoft\Data\Paginator\PaginatorInterface|null | ||
| 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 read( ): iterable | ||
| 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 readOne( ): array|object|null | ||
| 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 withFilter( Yiisoft\Data\Reader\FilterInterface $filter ): Yiisoft\Data\Paginator\PaginatorInterface | ||
| $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 withPageSize( integer $pageSize ): Yiisoft\Data\Paginator\PaginatorInterface | ||
| $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 withSort( Yiisoft\Data\Reader\Sort|null $sort ): Yiisoft\Data\Paginator\PaginatorInterface | ||
| $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 withToken( Yiisoft\Data\Paginator\PageToken|null $token ): Yiisoft\Data\Paginator\PaginatorInterface | ||
| $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.