2

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, or

    • by implementing setOffset and setLimit methods within my repo that would affect all of it's find... methods (which is not good due to the DefaultRepositoryFactory 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?

Community
  • 1
  • 1
G. Kashtanov
  • 401
  • 3
  • 11

1 Answers1

0

One possible solution I've discovered is to make a corresponding Filter (using LIMIT statement), as described in official documentation, and apply that filter to a repo before using it's query methods (including custom).

G. Kashtanov
  • 401
  • 3
  • 11