public function registerAction() { $this->view->country = $this->getTable('Country')->fetchAll(); $referer = $this->getRequest()->getParam('referer'); if (!empty($referer)) { $this->view->referer = $referer; } $form = new Form_UserRegister(); $form->setAction($this->_helper->url($this->getRequest()->getActionName())); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getParams())) { $creater = new Model_Creator_User($form->getValues()); try { $this->getDb()->beginTransaction(); $user = $creater->create(); if (!$this->getHelper('EmailVerification')->send($user, $user->email)) { $this->getHelper('FlashMessenger')->addMessage(array('noSentMail', 'warning')); } $this->getDb()->commit(); $this->getHelper('FlashMessenger')->addMessage('userCreated'); $this->_redirect('/'); } catch (Exception $e) { $this->getDb()->rollBack(); throw $e; } } } $this->view->form = $form; }
private function addUser($username) { $creator = new Model_Creator_User(array('username' => $username, 'password' => $username, 'countryCode' => 'UA', 'email' => $username . '@example.com', 'phone' => '+0800' . time())); $user = $creator->create(); $this->getHelper('EmailVerification')->send($user, $user->email); $this->getLog()->info("Add new user: {$user->username}"); return $this; }