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->setRoles(['ROLE_USER', 'ROLE_PLAYER']); $entityManager->persist($user); $entityManager->flush(); // generate a signed url and email it to the user $emailVerifier->sendEmailConfirmation('app_verify_email', $user, (new TemplatedEmail()) ->from('noreply@escapepage.dev') ->to($user->getEmail()) ->subject('Please Confirm your Email') ->htmlTemplate('tech/registration/confirmation_email.html.twig') ); $this->addFlash('success', 'A confirmation email has been sent to your email address.'); return $this->redirectToRoute('website_home'); } return $this->render('tech/registration/register.html.twig', [ 'registrationForm' => $form->createView(), ]); } }