geekcell / ddd-symfony-bundle

A bundle for pragmatic domain driven design in Symfony.
https://www.geekcell.io
MIT License
7 stars 1 forks source link

Add support for API Platform pagination. #12

Open b00gizm opened 1 year ago

b00gizm commented 1 year ago

Since 2.7 API Platform supports custom pagination aka pagination for custom state providers.

If you are using custom state providers (not the provided Doctrine ORM, ODM or ElasticSearch ones) and if you want your results to be paginated, you will need to return an instance of a ApiPlatform\State\Pagination\PartialPaginatorInterface or ApiPlatform\State\Pagination\PaginatorInterface. A few existing classes are provided to make it easier to paginate the results:

ApiPlatform\State\Pagination\ArrayPaginator ApiPlatform\State\Pagination\TraversablePaginator

Their definition is slightly different from the Paginator contract defined in geekcell/php-ddd, which probably calls for an adapter.

Since this is an optional feature and not all users might use API Platform and/or are already on 2.7 or higher, we should accommodate for this fact and avoid conflicts. Here's an example of how Symfony dealt with these kind of situations in the past.