[symfony6] knp paginator
Résolu
RomainGA
Messages postés
110
Date d'inscription
Statut
Membre
Dernière intervention
-
Pitet -
Pitet -
Bonjour,
<?php namespace App\Controller; use App\Repository\IngredientRepository; use Knp\Component\Pager\PaginatorInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; class IngredientController extends AbstractController { #[Route('/ingredient', name: 'app_ingredient')] public function index(IngredientRepository $repository, PaginatorInterface $paginator, Request $request): Response { $pagination = $paginator->paginate( $repository->findAll(), $request->query->getInt('page', 1), /*page number*/ 1 /*limit per page*/ ); $ingredients = $repository->findAll(); return $this->render('pages/ingredient/index.html.twig', [ 'ingredients'=>$ingredients ]); } }
A partir de la, je ne devrais avoir que 1 ingredient mais tout les ingredients s'affiche.

Que faire ?