src/Controller/RegistrationController.php line 21
<?phpnamespace App\Controller;use App\Controller\Bootstrap\DefaultLayoutController;use App\Entity\User;use App\Form\RegistrationFormType;use Doctrine\ORM\EntityManagerInterface;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Security\Http\Attribute\IsGranted;#[IsGranted("ROLE_ADMIN")]#[Route('/utilisateur')]class RegistrationController extends DefaultLayoutController{#[Route('/creation-compte', name: 'app_register')]public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, 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()));$entityManager->persist($user);$entityManager->flush();// do anything else you need here, like send an emailreturn $this->redirectToRoute('dashboard');}$this->theme->addJavascriptFile('js/custom/authentication/sign-up/general.js');return $this->render('pages/auth/signup.html.twig', ['form' => $form->createView()]);}}