class Pagination implements PaginationInterface

Pagination class.

Properties

protected int $items Number of items.
protected int $itemsPerPage Number of items per page.
protected int $currentPage Current page.
protected array $options Options.
protected int $pages Number of pages.
protected int $offset Offset.
protected Request $request Request instance.
protected array $params Query parameter cache.
protected URLBuilder $urlBuilder URL builder instance.
protected ViewFactory $viewFactory View factory instance.
protected array $pagination Pagination.

Methods

__construct(int $items, int $itemsPerPage, int $currentPage, array $options = [])

Constructor.

int
items()

Returns the number of items.

int
itemsPerPage()

Returns the number of items per page.

int
currentPage()

Returns the current page.

bool
isValidPage()

Returns TRUE if we're on a valid page and FALSE if not.

int
numberOfPages()

Returns the number pages.

int
limit()

Returns the limit.

int
offset()

Returns the offset.

setRequest(Request $request)

Sets the request instance.

setURLBuilder(URLBuilder $urlBuilder)

Sets the URL builder instance.

setViewFactory(ViewFactory $viewFactory)

Sets the view factory builder instance.

string
buildPageUrl(int $page)

Builds a url to the desired page.

array
toArray()

Returns an array representation of the pagination object.

array
jsonSerialize()

Returns data which can be serialized by json_encode().

string
toJson(int $options = 0)

Returns a json representation of the pagination object.

array
pagination()

Builds and returns the pagination array.

string
render(string $view)

Renders and returns the pagination partial.

Details

at line 108
__construct(int $items, int $itemsPerPage, int $currentPage, array $options = [])

Constructor.

Parameters

int $items Number of items
int $itemsPerPage Number of items per page
int $currentPage The current page
array $options Pagination options

at line 130
int items()

Returns the number of items.

Return Value

int

at line 138
int itemsPerPage()

Returns the number of items per page.

Return Value

int

at line 146
int currentPage()

Returns the current page.

Return Value

int

at line 154
bool isValidPage()

Returns TRUE if we're on a valid page and FALSE if not.

Return Value

bool

at line 162
int numberOfPages()

Returns the number pages.

Return Value

int

at line 170
int limit()

Returns the limit.

Return Value

int

at line 178
int offset()

Returns the offset.

Return Value

int

at line 188
setRequest(Request $request)

Sets the request instance.

Parameters

Request $request Request

at line 198
setURLBuilder(URLBuilder $urlBuilder)

Sets the URL builder instance.

Parameters

URLBuilder $urlBuilder URL builder instance

at line 208
setViewFactory(ViewFactory $viewFactory)

Sets the view factory builder instance.

Parameters

ViewFactory $viewFactory View factory instance

at line 219
protected string buildPageUrl(int $page)

Builds a url to the desired page.

Parameters

int $page Page

Return Value

string

at line 232
array toArray()

Returns an array representation of the pagination object.

Return Value

array

at line 262
array jsonSerialize()

Returns data which can be serialized by json_encode().

Return Value

array

at line 270
string toJson(int $options = 0)

Returns a json representation of the pagination object.

Parameters

int $options JSON encode options

Return Value

string

at line 280
array pagination()

Builds and returns the pagination array.

Return Value

array

at line 346
string render(string $view)

Renders and returns the pagination partial.

Parameters

string $view Pagination view

Return Value

string