Feature #102196
openSimplePagination: total number of items
0%
Description
There's all sort of getters that use the objects paginator (
ArrayPaginator
or QueryResultPaginator
) to ask for its properties:
getPreviousPageNumber()
calling->paginator->getCurrentPageNumber()
and->paginator->getNumberOfPages()
getNextPageNumber()
calling->paginator->getCurrentPageNumber()
and->paginator->getNumberOfPages()
getLastPageNumber()
calling->paginator->getNumberOfPages()
getStartRecordNumber()
calling->paginator->getCurrentPageNumber()
and->paginator->getNumberOfPages()
getEndRecordNumber()
calling->paginator->getCurrentPageNumber()
and->paginator->getNumberOfPages()
But no method to get the total number of records. So displaying a text like this is not possible:
Here's 10 out of a total of 321 records
Files
Updated by Georg Ringer 6 months ago
- Status changed from New to Accepted
what about adding a public method which returns getTotalAmountOfItems
?
Updated by Georg Ringer 6 months ago
- Complexity deleted (
easy) - Sprint Focus set to On Location Sprint
Updated by Marc Willmann 4 months ago
- File TER-example.png TER-example.png added
- Status changed from Accepted to Needs Feedback
- Assignee set to Philipp Kitzberger
I'm not sure if I understand the problem correctly. The PaginatorInterface
indeed lacks the named method; but the abstract implementation AbstractPaginator
has exactly this method
abstract protected function getTotalAmountOfItems(): int;
and as your examples ArrayPaginator
and QueryResultPaginator
extend the AbstractPaginator (and not implement the PaginatorInterface
on its own) they both have implemented the named method too (in different ways of course, but that's not an issue), e.g. the QueryResultPaginator
protected function getTotalAmountOfItems(): int
{
return count($this->queryResult);
}
The Extension TER-list is using the
SinglePagination
, which lacks this method. But there is the list of items already present itself, so you can easily count in this case {extensions}
(or any other array storing your data) to get the number needed.
Do you have a use-/test-case for your issue or does this already solve your problem?
Updated by Philipp Kitzberger 4 months ago ยท Edited
The Extension TER-list is using the SinglePagination, which lacks this method. But there is the list of items already present itself, so you can easily count in this case {extensions} (or any other array storing your data) to get the number needed.
I don't know this TER-list extension. But you mean SimplePagination, right? And with the list of items you mean the Paginator object that is separate from the Pagination object? Sure, one could use the Paginator objects getTotalAmountOfItems()
method.
But then why separate the logic into Pagination and Paginator at all when I have to use both in order to render the "usual scenario" as depict in your screenshot? Imagine a partial used to render the Pagination would always have both objects present. Thus I vote for adding either getPaginator()
or the beforementioned getTotalAmountOfItems()
to the SimplePagination and/or the PaginationInterface
.