|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
+use App\Dto\FiltersDTO;
|
|
|
use App\Entity\Commentaire;
|
|
|
use App\Entity\Realisateur;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
@@ -11,30 +12,45 @@ use Symfony\Component\HttpFoundation\Request;
|
|
|
use App\Entity\Film;
|
|
|
use App\Form\CommentaireType;
|
|
|
use App\Form\FilmType;
|
|
|
+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\FilmManager;
|
|
|
+use App\Service\FiltersService;
|
|
|
use App\Service\OptionsManager;
|
|
|
use App\Service\TmdbApiService;
|
|
|
use Symfony\Bundle\SecurityBundle\Security;
|
|
|
use Symfony\Component\Form\FormFactoryInterface;
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
-use Symfony\Component\Serializer\SerializerInterface;
|
|
|
|
|
|
class VideothequeController extends AbstractController
|
|
|
{
|
|
|
#[Route("/", name: "videotheque_liste")]
|
|
|
- public function listeAction(Request $request, FilmRepository $repo, OptionsManager $options): Response
|
|
|
+ public function listeAction(Request $request, FilmRepository $repo, OptionsManager $options, FiltersService $filtersService): Response
|
|
|
{
|
|
|
$listeFilms = $repo->findTous();
|
|
|
|
|
|
+ $filterDto = 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);
|
|
|
+ }
|
|
|
+
|
|
|
return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(
|
|
|
'listeFilms' => $listeFilms,
|
|
|
'titre' => 'Liste complète',
|
|
|
+ 'filtersForm' => $filtersForm->createView()
|
|
|
));
|
|
|
}
|
|
|
|