فهرست منبع

Ajout des types dans controllers

François Drouhard 2 سال پیش
والد
کامیت
e4244b5cf4

+ 6 - 4
src/Controller/GenreController.php

@@ -11,11 +11,13 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\Form\FormFactoryInterface;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
 
 class GenreController extends AbstractController
 {
     #[Route("/genre", name: "genre_liste")]
-    public function indexAction(GenreRepository $repo) {
+    public function indexAction(GenreRepository $repo): Response
+	{
         $genres = $repo->findAll();
 
         return $this->render('genre/liste.html.twig', array(
@@ -25,7 +27,7 @@ class GenreController extends AbstractController
 
 
 	#[Route("/genre/ajouter", name: "genre_ajouter")]
-	public function ajouterAction(Request $request, GenreManager $genreManager)
+	public function ajouterAction(Request $request, GenreManager $genreManager): Response
 	{
 		$genre = new Genre();
 		$form = $this->createForm(GenreType::class, $genre);
@@ -44,7 +46,7 @@ class GenreController extends AbstractController
 	}
 
 	 #[Route("/genre/modifier/{id}", name: "genre_modifier")]
-	public function modifierAction(Request $request, Genre $genre, FilmRepository $repo, GenreManager $genreManager)
+	public function modifierAction(Request $request, Genre $genre, FilmRepository $repo, GenreManager $genreManager): Response
 	{
 		$form = $this->createForm(GenreType::class, $genre);
 		$form->handleRequest($request);
@@ -65,7 +67,7 @@ class GenreController extends AbstractController
 	}
 
 	 #[Route("/genre/supprimer/{id}", name: "genre_supprimer")]
-	public function supprimerAction(Request $request, Genre $genre, GenreManager $genreManager, FormFactoryInterface $ffi)
+	public function supprimerAction(Request $request, Genre $genre, GenreManager $genreManager, FormFactoryInterface $ffi): Response
     {
         $form = $ffi->create();
         $form->handleRequest($request);

+ 1 - 4
src/Controller/ProfilController.php

@@ -15,7 +15,7 @@ class ProfilController extends AbstractController
 {
     
     #[Route("/profil/", name: "user_profil")]    
-    public function monProfilAction(Request $request, EntityManagerInterface $em)
+    public function monProfilAction(Request $request, EntityManagerInterface $em): Response
     {
         $user = $this->getUser();
         $form = $this->createForm(UserEditProfilType::class , $user);
@@ -27,13 +27,11 @@ class ProfilController extends AbstractController
             $this->addFlash('success', "Votre profil a été modifié");
         }
 
-
         return $this->renderForm('profil/monprofil.html.twig', array (
             'form'  =>  $form
         ));
     }
 
-    
     #[Route("/preferences/", name: "user_preferences")]
     public function mesPreferencesAction(Request $request, EntityManagerInterface $em, ProfileRepository $profileRepo): Response
     {
@@ -53,5 +51,4 @@ class ProfilController extends AbstractController
         ]);
     }
 
-
 }

+ 4 - 3
src/Controller/RealisateurController.php

@@ -11,6 +11,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\Form\FormFactoryInterface;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
 
 class RealisateurController extends AbstractController
 {
@@ -26,7 +27,7 @@ class RealisateurController extends AbstractController
 
 	
 	#[Route("/real/ajouter", name: "realisateur_ajouter")]	 
-	public function ajouterAction(Request $request, RealisateurManager $realisateurManager)
+	public function ajouterAction(Request $request, RealisateurManager $realisateurManager): Response
 	{
 		$realisateur = new Realisateur();
 		$form = $this->createForm(RealisateurType::class, $realisateur);
@@ -46,7 +47,7 @@ class RealisateurController extends AbstractController
 
 	
 	#[Route("/real/modifier/{id}", name: "realisateur_modifier")]
-	public function modifierAction(Request $request, Realisateur $realisateur, RealisateurManager $realisateurManager)
+	public function modifierAction(Request $request, Realisateur $realisateur, RealisateurManager $realisateurManager): Response
 	{
 		$form = $this->createForm(RealisateurType::class, $realisateur);
 		$form->handleRequest($request);
@@ -67,7 +68,7 @@ class RealisateurController extends AbstractController
 	
 	#[Route("/real/supprimer/{id}", name: "realisateur_supprimer")]
     #[IsGranted("ROLE_ADMIN")]
-	public function supprimerAction(Request $request, Realisateur $realisateur, RealisateurManager $realisateurManager, FormFactoryInterface $ffi)
+	public function supprimerAction(Request $request, Realisateur $realisateur, RealisateurManager $realisateurManager, FormFactoryInterface $ffi): Response
     {
 		$form = $ffi->create();
         $form->handleRequest($request);

+ 2 - 1
src/Controller/SearchController.php

@@ -6,13 +6,14 @@ use App\Service\OptionsManager;
 use App\Service\Search;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Routing\Annotation\Route;
 
 class SearchController extends AbstractController
 {
 
     #[Route("/recherche", name: "search_recherche")]
-    public function searchAction(Request $request, Search $filmSearch, OptionsManager $options)
+    public function searchAction(Request $request, Search $filmSearch, OptionsManager $options): Response
     {
         $query = $request->query->get('q', "");
         return $this->render('videotheque/liste_'.$options->vue().'.html.twig', array(

+ 10 - 10
src/Controller/SecurityController.php

@@ -44,7 +44,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/admin/createuser", name: "admin_createuser")]
-    public function createUserAction(Request $request, UserManager $userManager)
+    public function createUserAction(Request $request, UserManager $userManager): Response
     {
         $user = new User;
         $form = $this->createForm(UserType::class, $user);
@@ -62,7 +62,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/admin/edituser/{id}", name: "admin_edituser")]
-    public function editUserAction(Request $request, User $user, EntityManagerInterface $em)
+    public function editUserAction(Request $request, User $user, EntityManagerInterface $em): Response
     {
         $form = $this->createForm(UserEditType::class, $user);
         $form->handleRequest($request);
@@ -78,7 +78,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/admin/edituseroptions/{id}", name: "admin_edituseroptions")]
-    public function editUseroptions (Request $request, Profile $options, EntityManagerInterface $em)
+    public function editUseroptions (Request $request, Profile $options, EntityManagerInterface $em): Response
     {
         $form = $this->createForm(ProfileType::class, $options);
         $form->handleRequest($request);
@@ -97,7 +97,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/admin", name: "admin_index")]
-    public function indexAction(Request $request, UserRepository $repo)
+    public function indexAction(Request $request, UserRepository $repo): Response
     {
         $users = $repo->findAll();
 
@@ -107,7 +107,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/admin/deluser/{id}", name: "admin_deluser")]
-    public function delUserAction (Request $request, User $user, UserManager $userManager, FormFactoryInterface $ffi)
+    public function delUserAction (Request $request, User $user, UserManager $userManager, FormFactoryInterface $ffi): Response
     {
         $form = $ffi->create();
         $form->handleRequest($request);
@@ -123,7 +123,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/register", name: "security_register")]
-    public function registerAction(Request $request, UserManager $userManager, Mail $mail)
+    public function registerAction(Request $request, UserManager $userManager, Mail $mail): Response
     {
         $user = new User();
         $form = $this->createForm(UserRegisterType::class, $user);
@@ -146,7 +146,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/motdepasseoublie", name: "security_envoyertoken")]
-    public function recupMdpAction(Request $request, UserManager $userManager, Mail $mail, EntityManagerInterface $em, UserRepository $userRepo)
+    public function recupMdpAction(Request $request, UserManager $userManager, Mail $mail, EntityManagerInterface $em, UserRepository $userRepo): Response
     {
         $form = $this->createFormBuilder()
             ->add('email', EmailType::class)
@@ -177,7 +177,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/resetpassword/token={token}", name: "security_resetpassword")]
-    public function resetPasswordAction(Request $request, UserManager $userManager, User $user = null)
+    public function resetPasswordAction(Request $request, UserManager $userManager, User $user = null): Response
     {
         if ($user != null) {
             if ($user->isValidToken()) {
@@ -199,7 +199,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/admin/resettokens", name: "admin_resettokens")]
-    public function resetTokensAction(UserManager $userManager, EntityManagerInterface $em, UserRepository $userRepo)
+    public function resetTokensAction(UserManager $userManager, EntityManagerInterface $em, UserRepository $userRepo): Response
     {
         $users = $userRepo->findAll();
         foreach ($users as $user)
@@ -211,7 +211,7 @@ class SecurityController extends AbstractController
     }
 
     #[Route("/activate/token={token}", name: "security_activate")]
-    public function activateAction(Request $request, EntityManagerInterface $em, User $user = null)
+    public function activateAction(Request $request, EntityManagerInterface $em, User $user = null): Response
     {
         if ($user != null)
         {

+ 11 - 10
src/Controller/VideothequeController.php

@@ -21,12 +21,13 @@ use App\Service\CommentaireManager;
 use App\Service\FilmManager;
 use App\Service\OptionsManager;
 use Symfony\Component\Form\FormFactoryInterface;
+use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Serializer\SerializerInterface;
 
 class VideothequeController extends AbstractController
 {
 	#[Route("/", name: "videotheque_liste")]
-	public function listeAction(Request $request, FilmRepository $repo, OptionsManager $options)
+	public function listeAction(Request $request, FilmRepository $repo, OptionsManager $options): Response
 	{
         $listeFilms = $repo->findTous();
 
@@ -37,7 +38,7 @@ class VideothequeController extends AbstractController
     }
 
     #[Route("/prochaines-sorties", name: "prochaines_sorties")]
-    public function prochainesSorties(Request $request, FilmRepository $repo, OptionsManager $options)
+    public function prochainesSorties(Request $request, FilmRepository $repo, OptionsManager $options): Response
     {
         $listeFilms = $repo->findProchaines();
 
@@ -48,7 +49,7 @@ class VideothequeController extends AbstractController
     }
 
     #[Route("/liste-by/{id}", name: "videotheque_listepargenre")]
-	public function  listeParGenreAction(\App\Entity\Genre $genre, FilmRepository $repo, OptionsManager $options)
+	public function  listeParGenreAction(\App\Entity\Genre $genre, FilmRepository $repo, OptionsManager $options): Response
     {
         $films = $repo->findFilmWithGenre(array($genre->getName()));
 
@@ -59,7 +60,7 @@ class VideothequeController extends AbstractController
     }
 
     #[Route("/liste-by_real/{id}", name: "videotheque_listeparreal")]
-    public function  listeParRealisateurAction(Realisateur $realisateur, FilmRepository $repo, OptionsManager $options)
+    public function  listeParRealisateurAction(Realisateur $realisateur, FilmRepository $repo, OptionsManager $options): Response
     {
         $films = $repo->findFilmWithReal(array($realisateur->getNomComplet()));
 
@@ -70,7 +71,7 @@ class VideothequeController extends AbstractController
     }
 
 	#[Route("/ajouter", name: "videotheque_ajouter")]
-	public function ajouterAction(Request $request, FilmManager $filmManager)
+	public function ajouterAction(Request $request, FilmManager $filmManager): Response
 	{
 		$film = new Film;
 		$form = $this->createForm(FilmType::class, $film);
@@ -89,7 +90,7 @@ class VideothequeController extends AbstractController
 	}
 
 	#[Route("/modifier/{id}", name: "videotheque_modifier")]
-	public function modifierAction(Request $request, Film $film, FilmManager $filmManager)
+	public function modifierAction(Request $request, Film $film, FilmManager $filmManager): Response
 	{
 		$form = $this->createForm(FilmType::class, $film);
 		$form->handleRequest($request);
@@ -107,7 +108,7 @@ class VideothequeController extends AbstractController
 
 	#[Route("/supprimer/{id}", name: "videotheque_supprimer")]
     #[IsGranted("ROLE_ADMIN")]
-	public function supprimerAction(Request $request, Film $film, FilmManager $filmManager, FormFactoryInterface $ffi)
+	public function supprimerAction(Request $request, Film $film, FilmManager $filmManager, FormFactoryInterface $ffi): Response
 	{
         $form = $ffi->create();
         $form->handleRequest($request);
@@ -125,7 +126,7 @@ class VideothequeController extends AbstractController
 	}
 
 	#[Route("/fichefilm/{id}", name: "videotheque_voirfilm")]
-	public function voirFilmAction(Request $request, \App\Entity\Film $film, CommentaireManager $cm, Security $security, CommentaireRepository $repo)
+	public function voirFilmAction(Request $request, \App\Entity\Film $film, CommentaireManager $cm, Security $security, CommentaireRepository $repo): Response
     {
         if ($security->isGranted('IS_AUTHENTICATED_REMEMBERED'))
         {
@@ -153,7 +154,7 @@ class VideothequeController extends AbstractController
     }
 
     #[Route("/ajax_req_realisateurs", name: "videotheque_ajax_realisateurs")]
-    public function ajaxRealisateurs(RealisateurRepository $repo, SerializerInterface $serializer)
+    public function ajaxRealisateurs(RealisateurRepository $repo, SerializerInterface $serializer): Response
     {
         $realisateurs = $repo->findNomsComplets();
         $liste = array();
@@ -166,7 +167,7 @@ class VideothequeController extends AbstractController
     }
 
     #[Route("/ajax_req_genres", name: "videotheque_ajax_genres")]
-    public function ajaxGenres(GenreRepository $repo, SerializerInterface $serializer)
+    public function ajaxGenres(GenreRepository $repo, SerializerInterface $serializer): Response
     {
         $genres = $repo->findGenres();
         $liste = array();

+ 4 - 4
src/Controller/VideothequePersonnelleController.php

@@ -10,12 +10,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\JsonResponse;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Serializer\SerializerInterface;
+use Symfony\Component\HttpFoundation\Response;
 
 class VideothequePersonnelleController extends AbstractController
 {
 	#[Route("/maliste/", name:"videothequepersonnelle_maliste")]
-	public function maListeAction (Request $request, FilmRepository $repo, OptionsManager $options)
+	public function maListeAction (Request $request, FilmRepository $repo, OptionsManager $options): Response
     {
         $films = $repo->findTousFavoritesByUser($this->getUser());
 
@@ -26,7 +26,7 @@ class VideothequePersonnelleController extends AbstractController
     }
 
     #[Route("/maliste/modifieravoir/", name:"maliste_modifier_a_voir")]
-    public function modifierFilmDansListeAction(Request $request, EntityManagerInterface $em, FilmRepository $repo, FilmManager $filmManager)
+    public function modifierFilmDansListeAction(Request $request, EntityManagerInterface $em, FilmRepository $repo, FilmManager $filmManager): Response
     {
         $result = null;
         $film = $repo->find($request->request->get('id_film'));
@@ -40,7 +40,7 @@ class VideothequePersonnelleController extends AbstractController
     }
 
     #[Route("/maliste/modifiervus/", name:"maliste_modifier_vus")]
-    public function modifierFilmVusAction(Request $request, FilmRepository $repo, EntityManagerInterface $em, FilmManager $filmManager)
+    public function modifierFilmVusAction(Request $request, FilmRepository $repo, EntityManagerInterface $em, FilmManager $filmManager): Response
     {
         $result = null;