Browse Source

Passage des controllers en attribut php

François Drouhard 2 years ago
parent
commit
7fec06fd5d

+ 2 - 2
composer.json

@@ -2,7 +2,7 @@
     "type": "project",
     "license": "proprietary",
     "require": {
-        "php": "^7.3",
+        "php": "^8.1",
         "ext-ctype": "*",
         "ext-iconv": "*",
         "composer/package-versions-deprecated": "1.11.99.2",
@@ -50,7 +50,7 @@
     },
     "config": {
         "platform":{
-            "php": "7.3"
+            "php": "8.1"
         },
         "preferred-install": {
             "*": "dist"

File diff suppressed because it is too large
+ 174 - 304
composer.lock


+ 4 - 12
src/Controller/GenreController.php

@@ -14,9 +14,7 @@ use Symfony\Component\HttpFoundation\Request;
 
 class GenreController extends AbstractController
 {
-    /**
-     * @Route("/genre", name="genre_liste")
-     */
+    #[Route("/genre", name: "genre_liste")]
     public function indexAction(GenreRepository $repo) {
         $genres = $repo->findAll();
 
@@ -26,9 +24,7 @@ class GenreController extends AbstractController
     }
 
 
-	/**
-	 * @Route("/genre/ajouter", name="genre_ajouter")
-	 */
+	#[Route("/genre/ajouter", name: "genre_ajouter")]
 	public function ajouterAction(Request $request, GenreManager $genreManager)
 	{
 		$genre = new Genre();
@@ -47,9 +43,7 @@ class GenreController extends AbstractController
 		));
 	}
 
-	/**
-	 * @Route("/genre/modifier/{id}", name="genre_modifier")
-	 */
+	 #[Route("/genre/modifier/{id}", name: "genre_modifier")]
 	public function modifierAction(Request $request, Genre $genre, FilmRepository $repo, GenreManager $genreManager)
 	{
 		$form = $this->createForm(GenreType::class, $genre);
@@ -70,9 +64,7 @@ class GenreController extends AbstractController
 		));
 	}
 
-	/**
-	 * @Route("/genre/supprimer/{id}", name="genre_supprimer")
-	 */
+	 #[Route("/genre/supprimer/{id}", name: "genre_supprimer")]
 	public function supprimerAction(Request $request, Genre $genre, GenreManager $genreManager, FormFactoryInterface $ffi)
     {
         $form = $ffi->create();

+ 4 - 6
src/Controller/ProfilController.php

@@ -13,9 +13,8 @@ use Symfony\Component\Routing\Annotation\Route;
 
 class ProfilController extends AbstractController
 {
-    /**
-     * @Route("/profil/", name="user_profil")
-     */
+    
+    #[Route("/profil/", name: "user_profil")]    
     public function monProfilAction(Request $request, EntityManagerInterface $em)
     {
         $user = $this->getUser();
@@ -34,9 +33,8 @@ class ProfilController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/preferences/", name="user_preferences")
-     */
+    
+    #[Route("/preferences/", name: "user_preferences")]
     public function mesPreferencesAction(Request $request, EntityManagerInterface $em, ProfileRepository $profileRepo): Response
     {
         $profile = $profileRepo->findByUser($this->getUser());

+ 9 - 13
src/Controller/RealisateurController.php

@@ -14,9 +14,8 @@ use Symfony\Component\HttpFoundation\Request;
 
 class RealisateurController extends AbstractController
 {
-    /**
-     * @Route("/real/", name="realisateur_liste")
-     */
+    
+    #[Route("/real/", name: "realisateur_liste")]     
     public function indexAction(RealisateurRepository $repo) {
         $realisateurs = $repo->findAll();
 
@@ -25,9 +24,8 @@ class RealisateurController extends AbstractController
         ));
     }
 
-	/**
-	 * @Route("/real/ajouter", name="realisateur_ajouter")
-	 */
+	
+	#[Route("/real/ajouter", name: "realisateur_ajouter")]	 
 	public function ajouterAction(Request $request, RealisateurManager $realisateurManager)
 	{
 		$realisateur = new Realisateur();
@@ -46,9 +44,8 @@ class RealisateurController extends AbstractController
 		));
 	}
 
-	/**
-	 * @Route("/real/modifier/{id}", name="realisateur_modifier")
-	 */
+	
+	#[Route("/real/modifier/{id}", name: "realisateur_modifier")]
 	public function modifierAction(Request $request, Realisateur $realisateur, RealisateurManager $realisateurManager)
 	{
 		$form = $this->createForm(RealisateurType::class, $realisateur);
@@ -67,10 +64,9 @@ class RealisateurController extends AbstractController
 		));
 	}
 
-	/**
-	 * @Route("/real/supprimer/{id}", name="realisateur_supprimer")
-     * @IsGranted("ROLE_ADMIN")
-	 */
+	
+	#[Route("/real/supprimer/{id}", name: "realisateur_supprimer")]
+    #[IsGranted("ROLE_ADMIN")]
 	public function supprimerAction(Request $request, Realisateur $realisateur, RealisateurManager $realisateurManager, FormFactoryInterface $ffi)
     {
 		$form = $ffi->create();

+ 2 - 3
src/Controller/SearchController.php

@@ -10,9 +10,8 @@ use Symfony\Component\Routing\Annotation\Route;
 
 class SearchController extends AbstractController
 {
-    /**
-     * @Route("/recherche", name="search_recherche")
-     */
+
+    #[Route("/recherche", name: "search_recherche")]
     public function searchAction(Request $request, Search $filmSearch, OptionsManager $options)
     {
         $query = $request->query->get('q', "");

+ 12 - 37
src/Controller/SecurityController.php

@@ -26,9 +26,7 @@ use Symfony\Component\HttpFoundation\Response;
 
 class SecurityController extends AbstractController
 {
-    /**
-     * @Route("/login", name="app_login")
-     */
+    #[Route("/login", name: "app_login")]
     public function login(AuthenticationUtils $authenticationUtils): Response
     {
         // get the login error if there is one
@@ -39,17 +37,13 @@ class SecurityController extends AbstractController
         return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
     }
 
-    /**
-     * @Route("/logout", name="app_logout")
-     */
+    #[Route("/logout", name: "app_logout")]
     public function logout()
     {
         throw new \Exception('Don\'t forget to activate logout in security.yaml');
     }
 
-    /**
-     * @Route("/admin/createuser", name="admin_createuser")
-     */
+    #[Route("/admin/createuser", name: "admin_createuser")]
     public function createUserAction(Request $request, UserManager $userManager)
     {
         $user = new User;
@@ -67,9 +61,7 @@ class SecurityController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/admin/edituser/{id}", name="admin_edituser")
-     */
+    #[Route("/admin/edituser/{id}", name: "admin_edituser")]
     public function editUserAction(Request $request, User $user, EntityManagerInterface $em)
     {
         $form = $this->createForm(UserEditType::class, $user);
@@ -85,9 +77,7 @@ class SecurityController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/admin/edituseroptions/{id}", name="admin_edituseroptions")
-     */
+    #[Route("/admin/edituseroptions/{id}", name: "admin_edituseroptions")]
     public function editUseroptions (Request $request, Profile $options, EntityManagerInterface $em)
     {
         $form = $this->createForm(ProfileType::class, $options);
@@ -106,9 +96,7 @@ class SecurityController extends AbstractController
         ]);
     }
 
-    /**
-     * @Route("/admin", name="admin_index")
-     */
+    #[Route("/admin", name: "admin_index")]
     public function indexAction(Request $request, UserRepository $repo)
     {
         $users = $repo->findAll();
@@ -118,9 +106,7 @@ class SecurityController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/admin/deluser/{id}", name="admin_deluser")
-     */
+    #[Route("/admin/deluser/{id}", name: "admin_deluser")]
     public function delUserAction (Request $request, User $user, UserManager $userManager, FormFactoryInterface $ffi)
     {
         $form = $ffi->create();
@@ -136,9 +122,7 @@ class SecurityController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/register", name="security_register")
-     */
+    #[Route("/register", name: "security_register")]
     public function registerAction(Request $request, UserManager $userManager, Mail $mail)
     {
         $user = new User();
@@ -161,9 +145,7 @@ class SecurityController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/motdepasseoublie", name="security_envoyertoken")
-     */
+    #[Route("/motdepasseoublie", name: "security_envoyertoken")]
     public function recupMdpAction(Request $request, UserManager $userManager, Mail $mail, EntityManagerInterface $em, UserRepository $userRepo)
     {
         $form = $this->createFormBuilder()
@@ -194,9 +176,7 @@ class SecurityController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/resetpassword/token={token}", name="security_resetpassword")
-     */
+    #[Route("/resetpassword/token={token}", name: "security_resetpassword")]
     public function resetPasswordAction(Request $request, UserManager $userManager, User $user = null)
     {
         if ($user != null) {
@@ -218,10 +198,7 @@ class SecurityController extends AbstractController
 
     }
 
-    /**
-     * Ne pas utiliser
-     * @Route("/admin/resettokens", name="admin_resettokens")
-     */
+    #[Route("/admin/resettokens", name: "admin_resettokens")]
     public function resetTokensAction(UserManager $userManager, EntityManagerInterface $em, UserRepository $userRepo)
     {
         $users = $userRepo->findAll();
@@ -233,9 +210,7 @@ class SecurityController extends AbstractController
         return $this->redirectToRoute('admin_index');
     }
 
-    /**
-     * @Route("/activate/token={token}", name="security_activate")
-     */
+    #[Route("/activate/token={token}", name: "security_activate")]
     public function activateAction(Request $request, EntityManagerInterface $em, User $user = null)
     {
         if ($user != null)

+ 11 - 31
src/Controller/VideothequeController.php

@@ -25,9 +25,7 @@ use Symfony\Component\Serializer\SerializerInterface;
 
 class VideothequeController extends AbstractController
 {
-	/**
-	 * @Route("/", name="videotheque_liste")
-	 */
+	#[Route("/", name: "videotheque_liste")]
 	public function listeAction(Request $request, FilmRepository $repo, OptionsManager $options)
 	{
         $listeFilms = $repo->findTous();
@@ -38,9 +36,7 @@ class VideothequeController extends AbstractController
 		));
     }
 
-    /**
-     * @Route("/prochaines-sorties", name="prochaines_sorties")
-     */
+    #[Route("/prochaines-sorties", name: "prochaines_sorties")]
     public function prochainesSorties(Request $request, FilmRepository $repo, OptionsManager $options)
     {
         $listeFilms = $repo->findProchaines();
@@ -51,9 +47,7 @@ class VideothequeController extends AbstractController
 		));
     }
 
-    /**
-     * @Route("/liste-by/{id}", name="videotheque_listepargenre")
-     */
+    #[Route("/liste-by/{id}", name: "videotheque_listepargenre")]
 	public function  listeParGenreAction(\App\Entity\Genre $genre, FilmRepository $repo, OptionsManager $options)
     {
         $films = $repo->findFilmWithGenre(array($genre->getName()));
@@ -64,9 +58,7 @@ class VideothequeController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/liste-by_real/{id}", name="videotheque_listeparreal")
-     */
+    #[Route("/liste-by_real/{id}", name: "videotheque_listeparreal")]
     public function  listeParRealisateurAction(Realisateur $realisateur, FilmRepository $repo, OptionsManager $options)
     {
         $films = $repo->findFilmWithReal(array($realisateur->getNomComplet()));
@@ -77,9 +69,7 @@ class VideothequeController extends AbstractController
         ));
     }
 
-	/**
-	 * @Route("/ajouter", name="videotheque_ajouter")
-	 */
+	#[Route("/ajouter", name: "videotheque_ajouter")]
 	public function ajouterAction(Request $request, FilmManager $filmManager)
 	{
 		$film = new Film;
@@ -98,9 +88,7 @@ class VideothequeController extends AbstractController
 		));
 	}
 
-	/**
-	 * @Route("/modifier/{id}", name="videotheque_modifier")
-	 */
+	#[Route("/modifier/{id}", name: "videotheque_modifier")]
 	public function modifierAction(Request $request, Film $film, FilmManager $filmManager)
 	{
 		$form = $this->createForm(FilmType::class, $film);
@@ -117,10 +105,8 @@ class VideothequeController extends AbstractController
 		));
 	}
 
-	/**
-	 * @Route("/supprimer/{id}", name="videotheque_supprimer")
-     * @IsGranted("ROLE_ADMIN")
-	 */
+	#[Route("/supprimer/{id}", name: "videotheque_supprimer")]
+    #[IsGranted("ROLE_ADMIN")]
 	public function supprimerAction(Request $request, Film $film, FilmManager $filmManager, FormFactoryInterface $ffi)
 	{
         $form = $ffi->create();
@@ -138,9 +124,7 @@ class VideothequeController extends AbstractController
 		));
 	}
 
-	/**
-     * @Route("/fichefilm/{id}", name="videotheque_voirfilm")
-     */
+	#[Route("/fichefilm/{id}", name: "videotheque_voirfilm")]
 	public function voirFilmAction(Request $request, \App\Entity\Film $film, CommentaireManager $cm, Security $security, CommentaireRepository $repo)
     {
         if ($security->isGranted('IS_AUTHENTICATED_REMEMBERED'))
@@ -168,9 +152,7 @@ class VideothequeController extends AbstractController
         ));
     }
 
-    /**
-     * @Route("/ajax_req_realisateurs", name="videotheque_ajax_realisateurs")
-     */
+    #[Route("/ajax_req_realisateurs", name: "videotheque_ajax_realisateurs")]
     public function ajaxRealisateurs(RealisateurRepository $repo, SerializerInterface $serializer)
     {
         $realisateurs = $repo->findNomsComplets();
@@ -183,9 +165,7 @@ class VideothequeController extends AbstractController
         return new JsonResponse($liste);
     }
 
-    /**
-     * @Route("/ajax_req_genres", name="videotheque_ajax_genres")
-     */
+    #[Route("/ajax_req_genres", name: "videotheque_ajax_genres")]
     public function ajaxGenres(GenreRepository $repo, SerializerInterface $serializer)
     {
         $genres = $repo->findGenres();

+ 3 - 24
src/Controller/VideothequePersonnelleController.php

@@ -14,9 +14,7 @@ use Symfony\Component\Serializer\SerializerInterface;
 
 class VideothequePersonnelleController extends AbstractController
 {
-	/**
-     * @Route("/maliste/", name="videothequepersonnelle_maliste")
-     */
+	#[Route("/maliste/", name:"videothequepersonnelle_maliste")]
 	public function maListeAction (Request $request, FilmRepository $repo, OptionsManager $options)
     {
         $films = $repo->findTousFavoritesByUser($this->getUser());
@@ -27,22 +25,7 @@ class VideothequePersonnelleController extends AbstractController
         ));
     }
 
-
-	/*public function maListeAction (Request $request)
-    {
-        $resultats = array();
-        $user = $this->getUser();
-        foreach ($user->getFilms() as $key => $film) {
-            $resultats[$key] = $this->get('serializer')->serialize($film, 'json');
-        }
-        return new JsonResponse($resultats);
-    }*/
-
-    /**
-     * @Route("/maliste/modifieravoir/", name="maliste_modifier_a_voir")
-     * @param Request $request
-     * @return JsonResponse
-     */
+    #[Route("/maliste/modifieravoir/", name:"maliste_modifier_a_voir")]
     public function modifierFilmDansListeAction(Request $request, EntityManagerInterface $em, FilmRepository $repo, FilmManager $filmManager)
     {
         $result = null;
@@ -56,11 +39,7 @@ class VideothequePersonnelleController extends AbstractController
         return new JsonResponse((object)['newState' => $result]);
     }
 
-    /**
-     * @Route("/maliste/modifiervus/", name="maliste_modifier_vus")
-     * @param Request $request
-     * @return JsonResponse
-     */
+    #[Route("/maliste/modifiervus/", name:"maliste_modifier_vus")]
     public function modifierFilmVusAction(Request $request, FilmRepository $repo, EntityManagerInterface $em, FilmManager $filmManager)
     {
         $result = null;

Some files were not shown because too many files changed in this diff