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();
 }
 /**
  * @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;
     }
 }
 /**
  * @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;
 }