0 follower

Interface Yiisoft\Data\Paginator\PaginatorInterface

ExtendsYiisoft\Data\Reader\ReadableDataInterface
Implemented byYiisoft\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

Hide inherited methods

Method Description Defined By
getCurrentPageSize() Get number of items at the current page. Yiisoft\Data\Paginator\PaginatorInterface
getFilter() Returns data reader filter. Yiisoft\Data\Paginator\PaginatorInterface
getNextToken() Get token for the next page. Yiisoft\Data\Paginator\PaginatorInterface
getPageSize() Get the maximum number of items per page. Yiisoft\Data\Paginator\PaginatorInterface
getPreviousToken() Get token for the previous page. Yiisoft\Data\Paginator\PaginatorInterface
getSort() Get current sort object. Yiisoft\Data\Paginator\PaginatorInterface
getToken() Yiisoft\Data\Paginator\PaginatorInterface
isFilterable() Yiisoft\Data\Paginator\PaginatorInterface
isOnFirstPage() Get whether the current page is the first one. Yiisoft\Data\Paginator\PaginatorInterface
isOnLastPage() Get whether the current page is the last one. Yiisoft\Data\Paginator\PaginatorInterface
isPaginationRequired() Check that there is more than a single page so pagination is necessary. Yiisoft\Data\Paginator\PaginatorInterface
isSortable() Yiisoft\Data\Paginator\PaginatorInterface
nextPage() Get a data reader for the next page. Yiisoft\Data\Paginator\PaginatorInterface
previousPage() Get a data reader for the next page. Yiisoft\Data\Paginator\PaginatorInterface
read() Get an iterator that could be used to read currently active page items. Yiisoft\Data\Paginator\PaginatorInterface
readOne() Get one item from the data set. Which item is returned is up to implementation. Yiisoft\Data\Reader\ReadableDataInterface
withFilter() Returns new instance with data reading criteria set. Yiisoft\Data\Paginator\PaginatorInterface
withPageSize() Get a new instance with a page size set. Yiisoft\Data\Paginator\PaginatorInterface
withSort() Get a new instance with a sorting set. Yiisoft\Data\Paginator\PaginatorInterface
withToken() Get a new instance with page token. Yiisoft\Data\Paginator\PaginatorInterface

Constants

Hide inherited 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

Hide inherited methods

getCurrentPageSize() public abstract method

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;

            
getFilter() public abstract method

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;

            
getNextToken() public abstract method

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. null if the current page is last.

                public function getNextToken(): ?PageToken;

            
getPageSize() public abstract method

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;

            
getPreviousToken() public abstract method

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. null if current page is first.

                public function getPreviousToken(): ?PageToken;

            
getSort() public abstract method

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;

            
getToken() public abstract method

public abstract Yiisoft\Data\Paginator\PageToken|null getToken ( )
return Yiisoft\Data\Paginator\PageToken|null

Current page token or null if not set.

                public function getToken(): ?PageToken;

            
isFilterable() public abstract method

public abstract boolean isFilterable ( )
return boolean

Whether data reader does support filtering.

                public function isFilterable(): bool;

            
isOnFirstPage() public abstract method

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;

            
isOnLastPage() public abstract method

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;

            
isPaginationRequired() public abstract method

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;

            
isSortable() public abstract method

public abstract boolean isSortable ( )
return boolean

Whether changing sorting via {@see \Yiisoft\Data\Paginator\withSorting()} is supported.

                public function isSortable(): bool;

            
nextPage() public abstract method

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 null if on last page.

                public function nextPage(): ?static;

            
previousPage() public abstract method

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 null if on last page.

                public function previousPage(): ?static;

            
read() public abstract method

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;

            
readOne() public abstract method

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;

            
withFilter() public abstract method

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;

            
withPageSize() public abstract method

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;

            
withSort() public abstract method

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;

            
withToken() public abstract method

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. Null if current page is first.

return Yiisoft\Data\Paginator\PaginatorInterface

New instance.

throws Yiisoft\Data\Paginator\InvalidPageException

If page token is incorrect.

                public function withToken(?PageToken $token): static;