예제 #1
0
 /**
  * Sign Up action
  *
  * @return array|\Zend\Http\Response|ViewModel
  * @throws \Exception
  */
 public function indexAction()
 {
     $form = new Form\SignupForm('create-user', ['serviceLocator' => $this->getServiceLocator()]);
     if ($this->getRequest()->isPost()) {
         $form->setData($this->getRequest()->getPost());
         if ($form->isValid()) {
             $userService = new Service\User($this->getServiceLocator());
             try {
                 $user = $userService->create($form);
                 $this->flashMessenger()->addSuccessMessage('You must confirm your email address to complete registration');
                 return $this->redirect()->toRoute('home');
             } catch (\Exception $exception) {
                 throw $exception;
             }
         }
     }
     return new ViewModel(['form' => $form, 'serviceLocator' => $this->getServiceLocator()]);
 }