SimplePager
in package
Framework-level SimplePager - replaces per-plugin SimplePager implementations.
Compatible with QubitPager interface used by ahgThemeB5Plugin/_pager.php template. All methods match the interface expected by the template partial: haveToPaginate(), getNbResults(), getFirstIndice(), getLastIndice(), getPage(), getLastPage(), getLinks(), getResults(), etc.
Results are arrays (not objects) - templates access via $doc['slug'].
Table of Contents
Methods
- __construct() : mixed
- getFirstIndice() : int
- Get the 1-based index of the first item on the current page.
- getFirstPage() : int
- Get the first page number (always 1).
- getLastIndice() : int
- Get the 1-based index of the last item on the current page.
- getLastPage() : int
- Get the last page number.
- getLinks() : array<string|int, mixed>
- Get an array of page numbers centered on the current page.
- getMaxPerPage() : int
- Get the number of items per page.
- getNbResults() : int
- Get the total number of results across all pages.
- getNextPage() : int
- Get the next page number.
- getPage() : int
- Get the current page number (1-based).
- getPreviousPage() : int
- Get the previous page number.
- getResults() : array<string|int, mixed>
- Get the results for the current page.
- haveToPaginate() : bool
- Whether pagination is needed (total exceeds items per page).
- isFirstPage() : bool
- Check if this is the first page.
- isLastPage() : bool
- Check if this is the last page.
- setMaxPerPage() : void
- Set the number of items per page.
- setPage() : void
- Set the current page number.
Methods
__construct()
public
__construct(array<string|int, mixed> $results, int $total[, int $page = 1 ][, int $maxPerPage = 30 ]) : mixed
Parameters
- $results : array<string|int, mixed>
-
Pre-fetched results for the current page
- $total : int
-
Total number of results across all pages
- $page : int = 1
-
Current page number (1-based)
- $maxPerPage : int = 30
-
Items per page
getFirstIndice()
Get the 1-based index of the first item on the current page.
public
getFirstIndice() : int
Return values
intgetFirstPage()
Get the first page number (always 1).
public
getFirstPage() : int
Return values
intgetLastIndice()
Get the 1-based index of the last item on the current page.
public
getLastIndice() : int
Return values
intgetLastPage()
Get the last page number.
public
getLastPage() : int
Return values
intgetLinks()
Get an array of page numbers centered on the current page.
public
getLinks([int $nbLinks = 5 ]) : array<string|int, mixed>
Used by _pager.php to render page links. The algorithm matches the sfPager/QubitPager implementation exactly.
Parameters
- $nbLinks : int = 5
-
Maximum number of page links to show
Return values
array<string|int, mixed> —Array of page numbers (e.g., [3, 4, 5, 6, 7])
getMaxPerPage()
Get the number of items per page.
public
getMaxPerPage() : int
Return values
intgetNbResults()
Get the total number of results across all pages.
public
getNbResults() : int
Return values
intgetNextPage()
Get the next page number.
public
getNextPage() : int
Return values
intgetPage()
Get the current page number (1-based).
public
getPage() : int
Return values
intgetPreviousPage()
Get the previous page number.
public
getPreviousPage() : int
Return values
intgetResults()
Get the results for the current page.
public
getResults() : array<string|int, mixed>
Return values
array<string|int, mixed>haveToPaginate()
Whether pagination is needed (total exceeds items per page).
public
haveToPaginate() : bool
Return values
boolisFirstPage()
Check if this is the first page.
public
isFirstPage() : bool
Return values
boolisLastPage()
Check if this is the last page.
public
isLastPage() : bool
Return values
boolsetMaxPerPage()
Set the number of items per page.
public
setMaxPerPage(int $max) : void
Parameters
- $max : int
setPage()
Set the current page number.
public
setPage(int $page) : void
Parameters
- $page : int