Advertisement
Guest User

registerAction

a guest
Dec 22nd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. public function registerAction(Request $request)
  2.     {
  3.         $user = new User();
  4.  
  5.         $form = $this->createForm(UserType::class, $user);
  6.         $form->handleRequest($request);
  7.  
  8.         if ($form->isSubmitted() and $form->isValid()) {
  9.  
  10.             $confirmPassword = $request->request->get('confirmPassword');
  11.  
  12.             try{
  13.                 $this->userService->register($user, $confirmPassword);
  14.  
  15.             }catch (Exception $exception){
  16.                 $this->addFlash('message', $exception->getMessage());
  17.             }
  18.  
  19.             return $this->redirectToRoute("index");
  20.         }
  21.  
  22.         return $this->render("user/register.html.twig", [
  23.             'form' => $form->createView()
  24.         ]);
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement