Пример #1
0
 public function __invoke()
 {
     $user = $this->userRepository->authenticate($this->username, $this->password);
     if (false !== $user) {
         $this->session->set(LoginContext::LOGIN_VAR, $user->id());
         $this->redir->redirect(303, '/games');
         return;
     }
     $this->view->display('home.html', ['msg' => 'Invalid login']);
 }
Пример #2
0
 public function __invoke()
 {
     $games = $this->gameRepository->findAll();
     $viewGames = [];
     /** @var Game $game */
     foreach ($games as $game) {
         $viewGames[$game->owner()->displayName()][] = $game->title();
     }
     $viewData['gamesList'] = $viewGames;
     $this->view->display('games.html', $viewData);
 }
Пример #3
0
 public function handle($e)
 {
     $app = App::getInstance();
     while (ob_get_level() > 0) {
         ob_end_clean();
     }
     // header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
     if ($app->config('bono.debug') !== true) {
         if (isset($app->response)) {
             $app->response->setStatus(500);
         }
         if (isset($app->theme)) {
             $view = $app->theme->getView();
             $errorTemplate = 'error';
         } else {
             $view = new View();
             $errorTemplate = '../templates/error.php';
             if (is_readable($errorTemplate)) {
                 $view->setTemplatesDirectory('.');
             }
         }
         return $view->display($errorTemplate, array('error' => $e), 500);
     }
     return call_user_func_array(array($app->whoops, Run::EXCEPTION_HANDLER), func_get_args());
 }
Пример #4
0
 /**
  * Render a template
  *
  * Call this method within a GET, POST, PUT, DELETE, NOT FOUND, or ERROR
  * callable to render a template whose output is appended to the
  * current HTTP response body. How the template is rendered is
  * delegated to the current View.
  *
  * @param  string $template The name of the template passed into the view's render() method
  * @param  array  $data     Associative array of data made available to the view
  * @param  int    $status   The HTTP response status code to use (optional)
  */
 public function render($template, $data = array(), $status = null)
 {
     if (!is_null($status)) {
         $this->response->status($status);
     }
     $this->view->appendData($data);
     $this->view->display($template);
 }
Пример #5
0
 /**
  * Render a template
  *
  * Call this method within a GET, POST, PUT, DELETE, NOT FOUND, or ERROR
  * callable to render a template whose output is appended to the
  * current HTTP response body. How the template is rendered is
  * delegated to the current View.
  *
  * @param  string $template The name of the template passed into the view's render() method
  * @param  array  $data     Associative array of data made available to the view
  * @param  int    $status   The HTTP response status code to use (optional)
  */
 public function render($template, $data = array(), $status = null)
 {
     if (!is_null($status)) {
         $this->response->status($status);
     }
     $this->view->setTemplatesDirectory($this->config('templates.path'));
     $this->view->appendData($data);
     $this->view->display($template);
 }
Пример #6
0
 public function handle()
 {
     $app = App::getInstance();
     if ($app->config('bono.debug') !== true) {
         if (isset($app->response)) {
             $app->response->setStatus(404);
         }
         if (isset($app->theme)) {
             $view = $app->theme->getView();
             $errorTemplate = 'notFound';
         } else {
             $view = new View();
             $errorTemplate = '../templates/notFound.php';
             if (is_readable($errorTemplate)) {
                 $view->setTemplatesDirectory('.');
             }
         }
         return $view->display($errorTemplate, array(), 404);
     }
     $app->whoops->sendHttpCode(404);
     return call_user_func(array($app->whoops, Run::EXCEPTION_HANDLER), new RuntimeException("404 Resource not found"));
 }
Пример #7
0
 public function __invoke()
 {
     $this->view->display('home.html');
 }
Пример #8
0
 public function __invoke()
 {
     $this->view->display('register.html');
 }
Пример #9
0
 public function __invoke()
 {
     $this->view->display('games-create.html');
 }
 /**
  * @param  array  $resource
  * @return string
  */
 public function renderView(array $resource, Response $response)
 {
     $viewFormat = $this->getViewFormat($response);
     $this->view->setData(['resource' => $resource]);
     return $this->view->display("resource/show.{$viewFormat}.twig");
 }
 /**
  * @param array $errors
  */
 public function renderErrors(array $errors, Response $response)
 {
     $viewFormat = $this->getViewFormat($response);
     $this->view->setData(['errors' => ['messages' => $errors]]);
     return $this->view->display("error/errors.{$viewFormat}.twig");
 }