getUser(); // Vérifiez les rôles si nécessaire if (!$user) { throw $this->createAccessDeniedException('Vous devez être connecté pour accéder à cette page.'); } if ($user instanceof Intern) { $internApplications = $this->internApplicationRepository->findBy([ 'intern' => $user, ]); return $this->render('profile/index.html.twig', [ 'user' => $user, 'applications' => $internApplications ]); } return $this->render('profile/index.html.twig', [ 'user' => $user, 'applications' => [] ]); } #[Route('profile/{id}/edit', name: 'app_profile_edit', methods: ['GET', 'POST'])] public function edit(Request $request, UserApp $userApp, UserPasswordHasherInterface $passwordHasher): Response { $form = $this->createForm(UserAppType::class, $userApp); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $plainPassword = $form->get('password')->getData(); if (!empty($plainPassword)) { $hashedPassword = $passwordHasher->hashPassword($userApp, $plainPassword); $userApp->setPassword($hashedPassword); } $this->entityManager->flush(); return $this->redirectToRoute('app_profile', [], Response::HTTP_SEE_OTHER); } return $this->render('profile/edit.html.twig', [ 'user_app' => $userApp, 'form' => $form, ]); } #[Route('/profile/visit/{id}', name: 'app_profile_visit')] public function visitProfile(int $id): Response { $candidat = $this->entityManager->getRepository(Intern::class)->find($id); if (!$candidat) { throw $this->createNotFoundException('Utilisateur non trouvé.'); } return $this->render('profile/visit.html.twig', [ 'candidat' => $candidat, ]); } #[Route('profile/pickDegree', name: 'app_profile_pickDegree', methods: ['GET'])] public function pickDegree(UserApp $userApp): Response { return $this->render('degree/index.html.twig', [ 'user_app' => $userApp, ]); } #[Route('/profile/pickSkill', name: 'app_profile_pickSkill', methods: ['GET'])] public function pickSkill(UserApp $userApp): Response { return $this->render('skill/index.html.twig', [ 'user_app' => $userApp, ]); } }