src/Controller/SoundController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\SoundRepository;
  4. use APY\BreadcrumbTrailBundle\Annotation\Breadcrumb;
  5. use Knp\Component\Pager\PaginatorInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. #[Route('/sounds'name'app_sound_')]
  11. #[Breadcrumb(title'Titres')]
  12. class SoundController extends AbstractController
  13. {
  14.     #[Route('/'name'index')]
  15.     public function index(
  16.         SoundRepository $soundRepository,
  17.         PaginatorInterface $paginator,
  18.         Request $request
  19.     ): Response {
  20.         $pagination $paginator->paginate(
  21.             $soundRepository->queryFindAll(),
  22.             $request->query->getInt('page'1), /*page number*/
  23.             12 /*limit per page*/
  24.         );
  25.         return $this->render('sound/index.html.twig', [
  26.             'sounds' => $pagination,
  27.         ]);
  28.     }
  29. }