SHARE
TWEET

Untitled

a guest Sep 11th, 2019 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.      * @Route("/rejestracja", name="user_registration")
  3.      */
  4.     public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder)
  5.     {
  6.         $user = new AppUser();
  7.         $form = $this->createForm(AppUserType::class, $user);
  8.  
  9.         $form->handleRequest($request);
  10.        
  11.         if ($form->isSubmitted() && $form->isValid()) {
  12.  
  13.             $password = $passwordEncoder->encodePassword($user, $user->getPlainPassword());
  14.             $user->setPassword($password);
  15.             $user->eraseCredentials();
  16.             $entityManager = $this->getDoctrine()->getManager();
  17.             $entityManager->persist($user);
  18.             $entityManager->flush();
  19.  
  20.             return $this->redirectToRoute('main');
  21.         }
  22.  
  23.         return $this->render('security/register.html.twig', [
  24.             'controller_name'   =>  'registration',
  25.             'form' => $form->createView(),
  26.         ]);
  27.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top