mangati / paginator-bundle
Symfony4 paginator bundle
v1.1.0
2020-12-17 12:27 UTC
Requires
- doctrine/orm: ^2.5
- pagerfanta/doctrine-orm-adapter: ^2.5
- pagerfanta/pagerfanta: ^2.1
- symfony/http-foundation: ^4.2|^5.0
- symfony/routing: ^4.2|^5.0
This package is auto-updated.
Last update: 2024-11-06 18:31:08 UTC
README
Symfony 4+ paginator bundle.
Usage
Controller:
// app controller /** * @Route("/", name="my_index_route") */ public function index(Request $request, PaginatorFactory $paginatorFactory) { $qb = $this ->getDoctrine() ->getManager() ->createQueryBuilder() ->select('e', 's') ->from(Entity::class, 'e'); $query = $qb->getQuery(); $paginator = $paginatorFactory ->withExtraParams(['q']) ->create( $request, $query, 'my_index_route' ); return $this->render('index.html.twig', [ 'paginator' => $paginator, ]); }
View:
{# index.html.twig #} <table> <thead> <tr> ... </tr> </thead> <tbody> {% for entity in paginator.result %} <tr> ... </tr> {% endfor %} </tbody> </table> {{ paginator.html|raw }}