Ejemplo n.º 1
0
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $user = $this->input->getVar('registration');
     $user = new Data($user);
     $session = Ioc::getSession();
     $session['register.form.data'] = $user;
     $trans = Ioc::getDatabase()->getTransaction()->start();
     try {
         $this->validate($user);
         // User
         $user = $this->createUser($user);
         // Blog
         $blogCtrl = $this->createBlog($user);
         // Articles
         $this->createDefaultArticle($blogCtrl);
     } catch (ValidFailException $e) {
         $trans->rollback();
         $this->setRedirect(Router::buildHttp('user:registration'), $e->getMessage(), 'danger');
         return false;
     } catch (\Exception $e) {
         $trans->rollback();
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::buildHttp('user:registration'), 'Register fail', 'danger');
         return false;
     }
     $trans->commit();
     $session->remove('register.form.data');
     // OK let's login
     User::makeUserLogin($user->id);
     $this->setRedirect(Router::buildHttp('user:login'), 'Register success.', 'success');
     return true;
 }