예제 #1
0
 public function render()
 {
     $this->masterView->setAuth($this->authController->render());
     switch ($this->router->getCurrentPath()) {
         case Router::INDEX:
             $this->masterView->setMain($this->inputController->render());
             break;
         case Router::MY_DIAGRAMS:
             if ($this->auth->isLoggedIn()) {
                 $this->masterView->setMain($this->myDiagramsController->render());
             } else {
                 $this->router->redirectTo(Router::INDEX);
                 return null;
             }
             break;
         case Router::REGISTER:
             $this->masterView->setMain($this->authController->register());
             break;
         case Router::FILE:
             return $this->fileController->render();
         default:
             if ($this->router->isDiagram()) {
                 $this->masterView->setMain($this->inputController->render());
             } else {
                 $this->router->redirectTo(Router::INDEX);
                 return null;
             }
     }
     return $this->masterView->render();
 }
예제 #2
0
 /**
  * @return LoginView|UserView
  */
 public function render()
 {
     if ($this->auth->isLoggedIn() && $this->userView->haveLoggedOut()) {
         $this->auth->logOut();
         $this->credentialsHandler->deleteSecret();
         $this->router->redirectTo(Router::INDEX);
     } elseif (!$this->auth->isLoggedIn()) {
         if ($this->loginView->haveLoggedIn()) {
             $username = $this->loginView->getUsername();
             $password = $this->loginView->getPassword();
             if ($this->auth->logInByCredentials($username, $password)) {
                 $token = new Token($this->auth->getUser());
                 $this->tokenRepository->insert($token);
                 $this->credentialsHandler->saveSecret($token);
                 $this->router->redirectTo(Router::INDEX);
             } else {
                 $this->loginView->loginFailed();
             }
         } elseif ($this->credentialsHandler->hasSecret()) {
             $secret = $this->credentialsHandler->getSecret();
             try {
                 $token = $this->tokenRepository->getBySecret($secret);
                 $this->auth->logInByToken($token);
                 $this->router->redirectTo(Router::INDEX);
             } catch (\Exception $e) {
             }
         }
     }
     if ($this->auth->isLoggedIn()) {
         return $this->userView;
     } else {
         return $this->loginView;
     }
 }
예제 #3
0
 /**
  * @return InputView
  */
 public function render()
 {
     $id = $this->router->getDiagramId();
     if ($this->inputView->wantToSave()) {
         $diagram = new Diagram($id, $this->auth->getUser());
         $this->inputView->populateDiagram($diagram);
         if ($diagram->isValid()) {
             $this->diagramRepository->save($diagram);
             $this->router->redirectTo(str_replace('{id}', $diagram->getId(), Router::DIAGRAM_FORMAT));
         }
     } elseif (!$this->inputView->wantToRender() && $id != null) {
         $diagram = $this->diagramRepository->getById($id);
         $this->inputView->setName($diagram->getName());
         $this->inputView->setUmls($diagram->getUmls());
     }
     return $this->inputView;
 }