|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Controller;
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
+use App\Dto\FiltersDTO;
|
|
use App\Entity\Commentaire;
|
|
use App\Entity\Commentaire;
|
|
use App\Entity\Realisateur;
|
|
use App\Entity\Realisateur;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
@@ -9,6 +10,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use App\Entity\Genre;
|
|
use App\Entity\Genre;
|
|
use App\Form\CommentaireType;
|
|
use App\Form\CommentaireType;
|
|
|
|
+use App\Form\FiltersType;
|
|
use App\Repository\CommentaireRepository;
|
|
use App\Repository\CommentaireRepository;
|
|
use App\Repository\FilmRepository;
|
|
use App\Repository\FilmRepository;
|
|
use App\Repository\GenreRepository;
|
|
use App\Repository\GenreRepository;
|
|
@@ -16,22 +18,33 @@ use App\Repository\RealisateurRepository;
|
|
use App\Service\CommentaireManager;
|
|
use App\Service\CommentaireManager;
|
|
use App\Service\OptionsManager;
|
|
use App\Service\OptionsManager;
|
|
use App\Service\Pagination;
|
|
use App\Service\Pagination;
|
|
|
|
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Bundle\SecurityBundle\Security;
|
|
use Symfony\Bundle\SecurityBundle\Security;
|
|
|
|
+use Symfony\Component\Form\FormFactoryInterface;
|
|
|
|
+use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
+use Symfony\Component\HttpKernel\Attribute\MapQueryString;
|
|
|
|
|
|
-class VideothequeListController extends FilmAbstractController
|
|
|
|
|
|
+class VideothequeListController extends AbstractController
|
|
{
|
|
{
|
|
#[Route("/", name: "videotheque_liste")]
|
|
#[Route("/", name: "videotheque_liste")]
|
|
- public function listeAction(Request $request, FilmRepository $filmRepository, OptionsManager $options): Response
|
|
|
|
|
|
+ public function listeAction(
|
|
|
|
+ Request $request,
|
|
|
|
+ FilmRepository $filmRepository,
|
|
|
|
+ OptionsManager $options,
|
|
|
|
+ #[MapQueryString]
|
|
|
|
+ ?FiltersDTO $filters,
|
|
|
|
+ FormFactoryInterface $formFactory,
|
|
|
|
+ ): Response
|
|
{
|
|
{
|
|
- $page = (int)$request->get('p', 1);
|
|
|
|
- $page = $page > 0 ? $page : 1;
|
|
|
|
- if ($request->isMethod('POST')) {
|
|
|
|
- $page = 1;
|
|
|
|
- }
|
|
|
|
- $filtersForm = $this->formPagination($request);
|
|
|
|
- $qb = $filmRepository->queryTous($filtersForm->getData()->toArray(), $page);
|
|
|
|
- $pagination = new Pagination($qb, $filtersForm->getData()->nbResults, $page);
|
|
|
|
|
|
+ $filters = $filters ?? new FiltersDTO();
|
|
|
|
+ $filtersForm = $formFactory->createNamed('', FiltersType::class, $filters);
|
|
|
|
+
|
|
|
|
+ $filtersForm->handleRequest($request);
|
|
|
|
+ dump($filters);
|
|
|
|
+
|
|
|
|
+ $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(
|
|
return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
'listeFilms' => $pagination->getPaginator(),
|
|
'listeFilms' => $pagination->getPaginator(),
|
|
@@ -42,15 +55,30 @@ class VideothequeListController extends FilmAbstractController
|
|
}
|
|
}
|
|
|
|
|
|
#[Route("/maliste", name:"videothequepersonnelle_maliste")]
|
|
#[Route("/maliste", name:"videothequepersonnelle_maliste")]
|
|
- public function maListeAction (Request $request, OptionsManager $options, FilmRepository $filmRepository): Response
|
|
|
|
|
|
+ public function maListeAction (
|
|
|
|
+ Request $request,
|
|
|
|
+ FilmRepository $filmRepository,
|
|
|
|
+ OptionsManager $options,
|
|
|
|
+ #[MapQueryString]
|
|
|
|
+ ?FiltersDTO $filters,
|
|
|
|
+ FormFactoryInterface $formFactory,
|
|
|
|
+ ): Response
|
|
{
|
|
{
|
|
- $filtersForm = $this->formPagination($request);
|
|
|
|
- $listeFilms = $filmRepository->findTousFavoritesByUser($this->getUser(), $filtersForm->getData()->toArray());
|
|
|
|
- return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
|
|
- 'listeFilms' => $listeFilms,
|
|
|
|
|
|
+ $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',
|
|
'titre' => 'Ma liste de films à voir',
|
|
- 'filtersForm' => $filtersForm->createView()
|
|
|
|
- ));
|
|
|
|
|
|
+ 'filtersForm' => $filtersForm->createView(),
|
|
|
|
+ 'pagination' => $pagination
|
|
|
|
+ ));
|
|
}
|
|
}
|
|
|
|
|
|
#[Route("/prochaines-sorties", name: "prochaines_sorties")]
|
|
#[Route("/prochaines-sorties", name: "prochaines_sorties")]
|
|
@@ -65,29 +93,56 @@ class VideothequeListController extends FilmAbstractController
|
|
}
|
|
}
|
|
|
|
|
|
#[Route("/liste-by/{id}", name: "videotheque_listepargenre")]
|
|
#[Route("/liste-by/{id}", name: "videotheque_listepargenre")]
|
|
- public function listeParGenreAction(Request $request, Genre $genre, FilmRepository $repo, OptionsManager $options): Response
|
|
|
|
|
|
+ public function listeParGenreAction(
|
|
|
|
+ Request $request,
|
|
|
|
+ Genre $genre,
|
|
|
|
+ FilmRepository $filmRepository,
|
|
|
|
+ OptionsManager $options,
|
|
|
|
+ #[MapQueryString]
|
|
|
|
+ ?FiltersDTO $filters,
|
|
|
|
+ FormFactoryInterface $formFactory,
|
|
|
|
+ ): Response
|
|
{
|
|
{
|
|
- $filtersForm = $this->formPagination($request);
|
|
|
|
- $films = $repo->findFilmWithGenre([$genre->getName()], $filtersForm->getData()->toArray());
|
|
|
|
|
|
+ $filters = $filters ?? new FiltersDTO();
|
|
|
|
+ $filtersForm = $formFactory->createNamed('', FiltersType::class, $filters);
|
|
|
|
+
|
|
|
|
+ $filtersForm->handleRequest($request);
|
|
|
|
|
|
- return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
|
|
- 'listeFilms' => $films,
|
|
|
|
- 'titre' => 'Films par catégorie : '.$genre->getName(),
|
|
|
|
- 'filtersForm' => $filtersForm
|
|
|
|
- ));
|
|
|
|
|
|
+ $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")]
|
|
#[Route("/liste-by_real/{id}", name: "videotheque_listeparreal")]
|
|
- public function listeParRealisateurAction(Request $request, Realisateur $realisateur, FilmRepository $repo, OptionsManager $options): Response
|
|
|
|
|
|
+ public function listeParRealisateurAction(
|
|
|
|
+ Request $request,
|
|
|
|
+ Realisateur $realisateur,
|
|
|
|
+ FilmRepository $filmRepository,
|
|
|
|
+ OptionsManager $options,
|
|
|
|
+ #[MapQueryString]
|
|
|
|
+ ?FiltersDTO $filters,
|
|
|
|
+ FormFactoryInterface $formFactory,): Response
|
|
{
|
|
{
|
|
- $filtersForm = $this->formPagination($request);
|
|
|
|
- $films = $repo->findFilmWithReal([$realisateur->getNomComplet()], $filtersForm->getData()->toArray());
|
|
|
|
|
|
+ $filters = $filters ?? new FiltersDTO();
|
|
|
|
+ $filtersForm = $formFactory->createNamed('', FiltersType::class, $filters);
|
|
|
|
+
|
|
|
|
+ $filtersForm->handleRequest($request);
|
|
|
|
|
|
- return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
|
|
- 'listeFilms' => $films,
|
|
|
|
- 'titre' => 'Films par réalisateur : '.$realisateur->getNomComplet(),
|
|
|
|
- 'filtersForm' => $filtersForm
|
|
|
|
- ));
|
|
|
|
|
|
+ $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', array(
|
|
|
|
+ 'listeFilms' => $pagination->getPaginator(),
|
|
|
|
+ 'titre' => 'Films par réalisateur : ' . $realisateur->getNomComplet(),
|
|
|
|
+ 'filtersForm' => $filtersForm->createView(),
|
|
|
|
+ 'pagination' => $pagination
|
|
|
|
+ ));
|
|
}
|
|
}
|
|
|
|
|
|
#[Route("/fichefilm/{id}", name: "videotheque_voirfilm")]
|
|
#[Route("/fichefilm/{id}", name: "videotheque_voirfilm")]
|