src/Controller/VideoOnpcController.php line 63

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\VideoOnpc as Video;
  4. use App\Service\Slugify;
  5. use App\Entity\Etablissement;
  6. use Knp\Component\Pager\PaginatorInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. class VideoOnpcController extends AbstractController
  13. {
  14.     private const LIMIT 1000;
  15.     private const HEADERLIMIT 2// Nbre de video à afficher dans l'onglet du header
  16.     private const PER_PAGE 15;
  17.     /** @var Slugify */
  18.     private $slugify;
  19.     /** @var PaginatorInterface */
  20.     private $paginator;    
  21.     public function __construct(Slugify $slugifyPaginatorInterface $paginator)
  22.     {
  23.         $this->slugify $slugify;
  24.         $this->paginator $paginator;
  25.     }
  26.     /**
  27.      * @Route("/webtv/", name="video-onpc-liste", methods={"GET", "POST"})
  28.      */
  29.     public function list(Request $request): Response
  30.     {
  31.         $currentURL $request->getPathInfo();
  32.         $repositoryVideo $this->getDoctrine()->getRepository(Video::class);
  33.         $videos $repositoryVideo->findBy([], ['createdAt' => 'DESC']);
  34.         $videos $this->paginator->paginate(
  35.             $videos,
  36.             $request->query->getInt('page'1),
  37.             self::PER_PAGE
  38.         );
  39.         return $this->render('video-onpc/list.html.twig', [
  40.             'videos' => $videos,
  41.             'currentURL' => $currentURL,
  42.             // 'robots_tag' => "noindex,follow",
  43.         ]);
  44.     }
  45.     /**
  46.      * @Route("/webtv/{slug}", name="video-promo-fiche", methods={"GET", "POST"})
  47.      */
  48.     public function fiche(?Video $video): Response
  49.     {
  50.         if (!$video) {
  51.             return $this->redirectToRoute('video-onpc-liste', [], 301);
  52.         }
  53.         return $this->render('video-onpc/fiche.html.twig', [
  54.             'video' => $video,
  55.         ]);
  56.     }
  57. }