diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index 6f0de0f..abacea9 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -2,7 +2,11 @@ namespace App\Controller; +use App\Entity\UserApp; +use App\Form\UserAppType; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -23,6 +27,24 @@ class ProfileController extends AbstractController 'user' => $user, ]); } + + #[Route('profile/{id}/edit', name: 'app_profile_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(UserAppType::class, $userApp); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_profile', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('profile/edit.html.twig', [ + 'user_app' => $userApp, + 'form' => $form, + ]); + } } diff --git a/src/Controller/UserAppController.php b/src/Controller/UserAppController.php index 7af1863..87635ae 100644 --- a/src/Controller/UserAppController.php +++ b/src/Controller/UserAppController.php @@ -14,7 +14,7 @@ use Symfony\Component\Routing\Attribute\Route; #[Route('/user')] final class UserAppController extends AbstractController { - #[Route(name: 'app_user_app_index', methods: ['GET'])] + #[Route(name: 'app_user_index', methods: ['GET'])] public function index(UserRepository $userRepository): Response { return $this->render('user_app/index.html.twig', [ @@ -22,7 +22,7 @@ final class UserAppController extends AbstractController ]); } - #[Route('/{id}', name: 'app_user_app_show', methods: ['GET'])] + #[Route('/{id}', name: 'app_user_show', methods: ['GET'])] public function show(UserApp $userApp): Response { return $this->render('user_app/show.html.twig', [ @@ -30,7 +30,7 @@ final class UserAppController extends AbstractController ]); } - #[Route('/{id}/edit', name: 'app_user_app_edit', methods: ['GET', 'POST'])] + #[Route('/{id}/edit', name: 'app_user_edit', methods: ['GET', 'POST'])] public function edit(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response { $form = $this->createForm(UserAppType::class, $userApp); @@ -39,7 +39,7 @@ final class UserAppController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $entityManager->flush(); - return $this->redirectToRoute('app_user_app_index', [], Response::HTTP_SEE_OTHER); + return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER); } return $this->render('user_app/edit.html.twig', [ @@ -48,7 +48,7 @@ final class UserAppController extends AbstractController ]); } - #[Route('/{id}', name: 'app_user_app_delete', methods: ['POST'])] + #[Route('/{id}', name: 'app_user_delete', methods: ['POST'])] public function delete(Request $request, UserApp $userApp, EntityManagerInterface $entityManager): Response { if ($this->isCsrfTokenValid('delete'.$userApp->getId(), $request->getPayload()->getString('_token'))) { @@ -56,6 +56,6 @@ final class UserAppController extends AbstractController $entityManager->flush(); } - return $this->redirectToRoute('app_user_app_index', [], Response::HTTP_SEE_OTHER); + return $this->redirectToRoute('app_user_index', [], Response::HTTP_SEE_OTHER); } } diff --git a/src/Form/UserAppType.php b/src/Form/UserAppType.php index dbd2033..3af7796 100644 --- a/src/Form/UserAppType.php +++ b/src/Form/UserAppType.php @@ -13,7 +13,6 @@ class UserAppType extends AbstractType { $builder ->add('nickname') - ->add('roles') ->add('password') ->add('firstName') ->add('lastName') diff --git a/templates/base.html.twig b/templates/base.html.twig index 1b5a07a..f7bf832 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -31,10 +31,13 @@ FAQ Messagerie -
@@ -68,14 +71,8 @@Email: support@hegresphere.com
Téléphone: +33 1 23 45 67 89
- - Déconnexion - -© 2024 HegreSphere. Tous droits réservés.
-