Advertisement
Guest User

Untitled

a guest
May 6th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. public function registerAction()
  2. {
  3.     Doctrine_Manager::connection()->beginTransaction();
  4.  
  5.     try {
  6.         $form = new Form_User_Register();
  7.  
  8.         if ($this->_request->isPost()) {
  9.             if ($form->isValid($this->_request->getPost())) {
  10.                 $user = new Model_User();
  11.                 $user->email = $form->getValue('email');
  12.                 $user->password = $form->getValue('password');
  13.                 $user->save();
  14.  
  15.                 Doctrine_Manager::connection()->commit();
  16.  
  17.                 $this->_helper->success('Registration has been successfully completed. You can login now.');
  18.                 $this->_redirect('/login');
  19.             }
  20.         }
  21.  
  22.         $this->view->form = $form;
  23.     }
  24.     catch (Doctrine_Connection_Exception $e) {
  25.         if ($e->getPortableCode() == Doctrine_Core::ERR_ALREADY_EXISTS) {
  26.             Doctrine_Manager::connection()->rollback();
  27.             $this->registerAction();
  28.         }
  29.     }
  30.     catch (Exception $e) {
  31.         Doctrine_Manager::connection()->rollback();
  32.         throw $e;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement