src/Controller/RegistrationController.php line 26
<?phpnamespace App\Controller;use App\Entity\Personne;use App\Entity\User;use App\Form\CompleteProfilType;use App\Form\RegistrationFormType;use App\Repository\UserRepository;use App\Security\UserAuthenticator;use Doctrine\ORM\EntityManagerInterface;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Mailer\MailerInterface;use Symfony\Component\Mime\Address;use Symfony\Component\Mime\Email;use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface;use Symfony\Contracts\Translation\TranslatorInterface;class RegistrationController extends AbstractController{#[Route('/register', name: 'app_register')]public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, UserAuthenticatorInterface $userAuthenticator, UserAuthenticator $authenticator, EntityManagerInterface $entityManager): Response{$user = new User();$form = $this->createForm(RegistrationFormType::class, $user);$form->handleRequest($request);if ($form->isSubmitted() && $form->isValid()) {// encode the plain password$user->setPassword($userPasswordHasher->hashPassword($user,$form->get('plainPassword')->getData()));$user->setLog(1);$entityManager->persist($user);$entityManager->flush();// do anything else you need here, like send an emailreturn $userAuthenticator->authenticateUser($user,$authenticator,$request);}return $this->render('registration/register.html.twig', ['registrationForm' => $form->createView(),]);}#[Route('/completer/profile', name: 'app_completer_profile')]public function completerProfile(UserRepository $userRepository, Request $request, EntityManagerInterface $entityManager,MailerInterface $mailer): Response{$user = $userRepository->find($this->getUser()->getId());$personne=new Personne();// Remplacez cela par votre moyen d'obtenir l'utilisateur en cours$form = $this->createForm(CompleteProfilType::class,$personne );$form->handleRequest($request);if ($form->isSubmitted() && $form->isValid()) {$user->setOneConnexion(true);$personne->setUser($user);$entityManager->persist($user);$entityManager->persist($personne);$entityManager->flush();$this->addFlash('success', 'Profil mis à jour avec succès !');return $this->redirectToRoute('app_dashboard');}return $this->render('registration/completeProfile.html.twig', ['form'=> $form]);}}