| 
					
				 | 
			
			
				@@ -0,0 +1,213 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<?php 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+namespace App\Controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Dto\FiltersDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Entity\Commentaire; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Entity\Realisateur; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\HttpFoundation\JsonResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\Routing\Annotation\Route; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\HttpFoundation\Request; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Entity\Genre; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Form\CommentaireType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Form\FiltersType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Repository\CommentaireRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Repository\FilmRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Repository\GenreRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Repository\RealisateurRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Service\CommentaireManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Service\OptionsManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use App\Service\Pagination; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Bundle\SecurityBundle\Security; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\Form\FormFactoryInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\HttpFoundation\RedirectResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\HttpFoundation\Response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\HttpKernel\Attribute\MapQueryString; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class VideothequeListController extends AbstractController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	#[Route("/", name: "videotheque_liste")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public function listeAction( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request $request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FilmRepository $filmRepository, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OptionsManager $options, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        #[MapQueryString] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ?FiltersDTO $filters, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FormFactoryInterface $formFactory, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filters = $filters ?? new FiltersDTO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm = $formFactory->createNamed('', FiltersType::class, $filters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm->handleRequest($request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $qb = $filmRepository->queryTous($filtersForm->getData()->page, $filtersForm->getData()->toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $pagination = new Pagination($qb, $filtersForm->getData()->limit, $filtersForm->getData()->page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'listeFilms'	=>	$pagination->getPaginator(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'titre'         =>  'Liste complète', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'filtersForm'   =>  $filtersForm->createView(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'pagination'    =>  $pagination 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[Route("/maliste", name:"videothequepersonnelle_maliste")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public function maListeAction ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request $request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FilmRepository $filmRepository, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OptionsManager $options, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        #[MapQueryString] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ?FiltersDTO $filters, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FormFactoryInterface $formFactory, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filters = $filters ?? new FiltersDTO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filters->userWantToView = $this->getUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm = $formFactory->createNamed('', FiltersType::class, $filters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm->handleRequest($request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $qb = $filmRepository->queryTous($filtersForm->getData()->page, $filtersForm->getData()->toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $pagination = new Pagination($qb, $filtersForm->getData()->limit, $filtersForm->getData()->page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'listeFilms'	=>	$pagination->getPaginator(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'titre'         =>  'Ma liste de films à voir', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'filtersForm'   =>  $filtersForm->createView(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'pagination'    =>  $pagination 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[Route("/prochaines-sorties", name: "prochaines_sorties")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function prochainesSorties(FilmRepository $repo, OptionsManager $options): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $listeFilms = $repo->findProchaines(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'listeFilms'	=>	$listeFilms, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'titre'         =>  'Prochaines sorties et films en salle', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[Route("/liste-by/{id}", name: "videotheque_listepargenre")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public function listeParGenreAction( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request $request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Genre $genre, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FilmRepository $filmRepository, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OptionsManager $options, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        #[MapQueryString] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ?FiltersDTO $filters, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FormFactoryInterface $formFactory, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filters = $filters ?? new FiltersDTO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm = $formFactory->createNamed('', FiltersType::class, $filters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm->handleRequest($request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $qb = $filmRepository->queryFilmWithGenre([$genre->getName()], $filtersForm->getData()->page, $filtersForm->getData()->toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $pagination = new Pagination($qb, $filtersForm->getData()->limit, $filtersForm->getData()->page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'listeFilms'	=>	$pagination->getPaginator(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'titre'         =>  'Films par genre : ' . $genre->getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'filtersForm'   =>  $filtersForm->createView(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'pagination'    =>  $pagination 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[Route("/liste-by_real/{id}", name: "videotheque_listeparreal")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function  listeParRealisateurAction( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request $request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Realisateur $realisateur, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FilmRepository $filmRepository, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OptionsManager $options, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        #[MapQueryString] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ?FiltersDTO $filters, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FormFactoryInterface $formFactory,): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filters = $filters ?? new FiltersDTO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm = $formFactory->createNamed('', FiltersType::class, $filters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $filtersForm->handleRequest($request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $qb = $filmRepository->queryFilmWithReal([$realisateur->getNomComplet()], $filtersForm->getData()->page, $filtersForm->getData()->toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $pagination = new Pagination($qb, $filtersForm->getData()->limit, $filtersForm->getData()->page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return $this->render('videotheque/liste_'.$options->vue().'.html.twig', [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'listeFilms'	=>	$pagination->getPaginator(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'titre'         =>  'Films par réalisateur : ' . $realisateur->getNomComplet(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'filtersForm'   =>  $filtersForm->createView(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'pagination'    =>  $pagination 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[Route('/pif', name: 'videotheque_random')] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function randomAction(FilmRepository $filmRepository, OptionsManager $options): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $films = $filmRepository->findRandom(5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return $this->render('videotheque/liste_'.$options->vue().'.html.twig', [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'listeFilms'    => $films, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'titre'         => '5 films au hasard' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	#[Route("/fichefilm/{id}", name: "videotheque_voirfilm")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public function voirFilmAction(Request $request, \App\Entity\Film $film, CommentaireManager $cm, Security $security, CommentaireRepository $repo): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ($security->isGranted('IS_AUTHENTICATED_REMEMBERED')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $commentaireUser = $repo->findOneBy(array('film'=>$film, 'user'=>$this->getUser())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (is_null($commentaireUser)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $commentaireUser = new Commentaire(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $form = $this->createForm(CommentaireType::class, $commentaireUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $form->handleRequest($request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ($form->isSubmitted() && $form->isValid()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $cm->delEditAdd($commentaireUser, $film); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $this->addFlash('success', 'Le commentaire a été posté'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return $this->redirectToRoute('videotheque_voirfilm', array('id' => $film->getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $form = $this->createForm(CommentaireType::class, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return $this->render('videotheque/voirfilm.html.twig', array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'film' => $film, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'form'  =>  $form 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[Route("/ajax_req_realisateurs", name: "videotheque_ajax_realisateurs")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function ajaxRealisateurs(Request $request, RealisateurRepository $repo): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $query = $request->query->get('query'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $realisateurs = $repo->findRealisateurLike($query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $liste = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        foreach ($realisateurs as $realisateur) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $liste[] = $realisateur->getNomComplet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return new JsonResponse($liste); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #[Route("/ajax_req_genres", name: "videotheque_ajax_genres")] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function ajaxGenres(Request $request, GenreRepository $repo): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $query = $request->query->get('query'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $genres = $repo->findGenreLike($query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $liste = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        foreach ($genres as $genre) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $liste[] = $genre->getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return new JsonResponse($liste); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |