Feature: #102194 - Introduce QueryBuilderPaginator
See forge#102194
Description
A new
\TYPO3\ is introduced to
enable pagination of
\TYPO3\
instances directly.
The paginator implements the existing
\TYPO3\ and integrates seamlessly
with the existing
\TYPO3\ and
\TYPO3\ classes.
The paginated items are fetched only once per page request by storing the result internally, avoiding double execution of the database statement.
The total item count is determined robustly using a common table expression
(CTE) wrapping the passed
Query instance. This approach correctly
handles advanced queries involving UNION, nested CTEs, windowing functions,
or grouping.
Note
The
Query does not handle language overlays.
Applying overlays on the result set can lead to unexpected item count
differences between pages when some records are hidden after overlay
processing. Use
\TYPO3\ or
\TYPO3\ when language overlay
handling is required.
The paginator also takes full control over LIMIT and OFFSET
and does not respect any existing limit/offset constraints on the passed
Query instance.
Impact
A new
Query is available to paginate
Query result sets using the standard TYPO3 pagination API.
Example
use TYPO3\CMS\Core\Pagination\QueryBuilderPaginator;
use TYPO3\CMS\Core\Pagination\SimplePagination;
$paginator = new QueryBuilderPaginator(
queryBuilder: $queryBuilder,
currentPageNumber: $currentPage,
itemsPerPage: 10,
);
$pagination = new SimplePagination($paginator);
// Retrieve the items for the current page
$items = $paginator->getPaginatedItems();