I'm aware of Doctrine's Paginator, but it works on DQL level. What I'm looking for is a way to implement pagination on repository level.
The first way I see is to incapsulate pagination within the repo:
by making all of it's methods accept two additional arguments,
$offset
and$limit
, orby implementing
setOffset
andsetLimit
methods within my repo that would affect all of it'sfind...
methods (which is not good due to theDefaultRepositoryFactory
implementation, which behaves as a Singleton Factory).
The other way is to make a
ResultBuilder
class as in this question. I don't really like this approach because it works on a prefetched result set, which makes extra data retrieval even with Doctrine's lazy-loading.
Which other approaches to the subject exist, and which approach would be the best for a Doctrine2 ORM user?