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 111
__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 133
int items()

Returns the number of items.

Return Value

int

at line 141
int itemsPerPage()

Returns the number of items per page.

Return Value

int

at line 149
int currentPage()

Returns the current page.

Return Value

int

at line 157
bool isValidPage()

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

Return Value

bool

at line 165
int numberOfPages()

Returns the number pages.

Return Value

int

at line 173
int limit()

Returns the limit.

Return Value

int

at line 181
int offset()

Returns the offset.

Return Value

int

at line 191
setRequest(Request $request)

Sets the request instance.

Parameters

Request $request Request

at line 201
setURLBuilder(URLBuilder $urlBuilder)

Sets the URL builder instance.

Parameters

URLBuilder $urlBuilder URL builder instance

at line 211
setViewFactory(ViewFactory $viewFactory)

Sets the view factory builder instance.

Parameters

ViewFactory $viewFactory View factory instance

at line 222
protected string buildPageUrl(int $page)

Builds a url to the desired page.

Parameters

int $page Page

Return Value

string

at line 235
array toArray()

Returns an array representation of the pagination object.

Return Value

array

at line 265
array jsonSerialize()

Returns data which can be serialized by json_encode().

Return Value

array

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

Returns a json representation of the pagination object.

Parameters

int $options JSON encode options

Return Value

string

at line 283
array pagination()

Builds and returns the pagination array.

Return Value

array

at line 349
string render(string $view)

Renders and returns the pagination partial.

Parameters

string $view Pagination view

Return Value

string