|
@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
use App\Entity\Film;
|
|
|
+use App\Entity\Genre;
|
|
|
use App\Form\CommentaireType;
|
|
|
use App\Form\FilmType;
|
|
|
use App\Form\FiltersType;
|
|
@@ -19,7 +20,6 @@ use App\Repository\GenreRepository;
|
|
|
use App\Repository\RealisateurRepository;
|
|
|
use App\Service\CommentaireManager;
|
|
|
use App\Service\FilmManager;
|
|
|
-use App\Service\FiltersService;
|
|
|
use App\Service\OptionsManager;
|
|
|
use App\Service\TmdbApiService;
|
|
|
use Symfony\Bundle\SecurityBundle\Security;
|
|
@@ -30,22 +30,20 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
class VideothequeController extends AbstractController
|
|
|
{
|
|
|
#[Route("/", name: "videotheque_liste")]
|
|
|
- public function listeAction(Request $request, FilmRepository $repo, OptionsManager $options, FiltersService $filtersService): Response
|
|
|
+ public function listeAction(Request $request, FilmRepository $filmRepository, OptionsManager $options): Response
|
|
|
{
|
|
|
- $listeFilms = $repo->findTous();
|
|
|
+ $session = $request->getSession();
|
|
|
|
|
|
- $filterDto = new FiltersDTO();
|
|
|
+ $filterDto = $session->get('filters', new FiltersDTO());
|
|
|
$filtersForm = $this->createForm(FiltersType::class, $filterDto);
|
|
|
|
|
|
$filtersForm->handleRequest($request);
|
|
|
|
|
|
if ($filtersForm->isSubmitted() && $filtersForm->isValid()) {
|
|
|
- // Récupérer les données de tri et de filtre
|
|
|
- $filters = $filtersForm->getData();
|
|
|
-
|
|
|
- // Appliquer les filtres et les tris
|
|
|
- $listeFilms = $filtersService->applyFiltersAndSort($listeFilms, $filters);
|
|
|
+ $session->set('filters', $filterDto);
|
|
|
}
|
|
|
+ $filters = $filtersForm->getData();
|
|
|
+ $listeFilms = $filmRepository->findTous($filters->toArray());
|
|
|
|
|
|
return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
|
'listeFilms' => $listeFilms,
|
|
@@ -66,24 +64,48 @@ class VideothequeController extends AbstractController
|
|
|
}
|
|
|
|
|
|
#[Route("/liste-by/{id}", name: "videotheque_listepargenre")]
|
|
|
- public function listeParGenreAction(\App\Entity\Genre $genre, FilmRepository $repo, OptionsManager $options): Response
|
|
|
+ public function listeParGenreAction(Request $request, Genre $genre, FilmRepository $repo, OptionsManager $options): Response
|
|
|
{
|
|
|
- $films = $repo->findFilmWithGenre(array($genre->getName()));
|
|
|
+ $session = $request->getSession();
|
|
|
+
|
|
|
+ $filterDto = $session->get('filters', new FiltersDTO());
|
|
|
+ $filtersForm = $this->createForm(FiltersType::class, $filterDto);
|
|
|
+
|
|
|
+ $filtersForm->handleRequest($request);
|
|
|
+
|
|
|
+ if ($filtersForm->isSubmitted() && $filtersForm->isValid()) {
|
|
|
+ $session->set('filters', $filterDto);
|
|
|
+ }
|
|
|
+ $filters = $filtersForm->getData();
|
|
|
+ $films = $repo->findFilmWithGenre([$genre->getName()], $filters->toArray());
|
|
|
|
|
|
return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
|
'listeFilms' => $films,
|
|
|
- 'titre' => 'Films par catégorie : '.$genre->getName()
|
|
|
+ 'titre' => 'Films par catégorie : '.$genre->getName(),
|
|
|
+ 'filtersForm' => $filtersForm
|
|
|
));
|
|
|
}
|
|
|
|
|
|
#[Route("/liste-by_real/{id}", name: "videotheque_listeparreal")]
|
|
|
- public function listeParRealisateurAction(Realisateur $realisateur, FilmRepository $repo, OptionsManager $options): Response
|
|
|
+ public function listeParRealisateurAction(Request $request, Realisateur $realisateur, FilmRepository $repo, OptionsManager $options): Response
|
|
|
{
|
|
|
- $films = $repo->findFilmWithReal(array($realisateur->getNomComplet()));
|
|
|
+ $session = $request->getSession();
|
|
|
+
|
|
|
+ $filterDto = $session->get('filters', new FiltersDTO());
|
|
|
+ $filtersForm = $this->createForm(FiltersType::class, $filterDto);
|
|
|
+
|
|
|
+ $filtersForm->handleRequest($request);
|
|
|
+
|
|
|
+ if ($filtersForm->isSubmitted() && $filtersForm->isValid()) {
|
|
|
+ $session->set('filters', $filterDto);
|
|
|
+ }
|
|
|
+ $filters = $filtersForm->getData();
|
|
|
+ $films = $repo->findFilmWithReal([$realisateur->getNomComplet()], $filters->toArray());
|
|
|
|
|
|
return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
|
'listeFilms' => $films,
|
|
|
- 'titre' => 'Films par réalisateur : '.$realisateur->getNomComplet()
|
|
|
+ 'titre' => 'Films par réalisateur : '.$realisateur->getNomComplet(),
|
|
|
+ 'filtersForm' => $filtersForm
|
|
|
));
|
|
|
}
|
|
|
|