Exemple #1
0
 /**
  * @Route("/register", name="user_register")
  * @Template()
  */
 public function registerAction()
 {
     $user = new User();
     $form = $this->createForm($this->userType, $user);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bind($this->getRequest());
         if ($form->isValid()) {
             $this->userManager->register($user);
             $redirectUrl = $this->getRequest()->getSession()->get('_security.app.target_path');
             if (!$redirectUrl) {
                 $redirectUrl = $this->generateUrl('post_list');
             }
             return $this->redirect($redirectUrl);
         }
     }
     return array('form' => $form->createView());
 }