- Full name:
\App\Infrastructure\Services\Paginator
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
NUM_PLACEHOLDER |
public | '(:num)' |
Properties
totalItems
numPages
itemsPerPage
currentPage
urlPattern
maxPagesToShow
previousText
nextText
Methods
__construct
public __construct(int $totalItems, int $itemsPerPage, int $currentPage, string $urlPattern = ''): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$totalItems |
int | The total number of items. |
$itemsPerPage |
int | The number of items per page. |
$currentPage |
int | The current page number. |
$urlPattern |
string | A URL for each page, with (:num) as a placeholder |
| for the page number. Ex. '/foo/page/(:num)' |
updateNumPages
setMaxPagesToShow
Parameters:
| Parameter | Type | Description |
|---|---|---|
$maxPagesToShow |
int |
Throws:
if $maxPagesToShow is less than 3.
- TypeException
getMaxPagesToShow
setCurrentPage
Parameters:
| Parameter | Type | Description |
|---|---|---|
$currentPage |
int |
getCurrentPage
setItemsPerPage
Parameters:
| Parameter | Type | Description |
|---|---|---|
$itemsPerPage |
int |
getItemsPerPage
setTotalItems
Parameters:
| Parameter | Type | Description |
|---|---|---|
$totalItems |
int |
getTotalItems
getNumPages
setUrlPattern
Parameters:
| Parameter | Type | Description |
|---|---|---|
$urlPattern |
string |
getUrlPattern
getPageUrl
Parameters:
| Parameter | Type | Description |
|---|---|---|
$pageNum |
int |
getNextPage
getPrevPage
getNextUrl
getPrevUrl
getPages
Get an array of paginated page data.
Example: [ ['num' => 1, 'url' => '/example/page/1', 'isCurrent' => false], ['num' => '...', 'url' => NULL, 'isCurrent' => false], ['num' => 3, 'url' => '/example/page/3', 'isCurrent' => false], ['num' => 4, 'url' => '/example/page/4', 'isCurrent' => true ], ['num' => 5, 'url' => '/example/page/5', 'isCurrent' => false], ['num' => '...', 'url' => NULL, 'isCurrent' => false], ['num' => 10, 'url' => '/example/page/10', 'isCurrent' => false], ]
createPage
Create a page data structure.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$pageNum |
int | |
$isCurrent |
bool |
createPageEllipsis
toHtml
Render an HTML pagination control.
__toString
getCurrentPageFirstItem
getCurrentPageLastItem
setPreviousText
Parameters:
| Parameter | Type | Description |
|---|---|---|
$text |
string |
setNextText
Parameters:
| Parameter | Type | Description |
|---|---|---|
$text |
string |