Example #1
0
 public function handle($uri = null)
 {
     /** @var Response $response */
     $response = parent::handle($uri);
     if ($response->getContent()) {
         return $response;
     }
     switch ($response->getStatusCode()) {
         case Response::HTTP_NOT_FOUND:
         case Response::HTTP_METHOD_NOT_ALLOWED:
         case Response::HTTP_UNAUTHORIZED:
         case Response::HTTP_FORBIDDEN:
         case Response::HTTP_INTERNAL_SERVER_ERROR:
             if ($this->request->isAjax() || $response instanceof JsonResponse) {
                 $response->setContent(array('error' => $response->getStatusMessage()));
             } else {
                 $template = new Template($this->view, 'error');
                 $template->set('code', $response->getStatusCode());
                 $template->set('message', $response->getStatusMessage());
                 $response->setContent($template->render());
             }
             break;
         default:
             break;
     }
     return $response;
 }
 /**
  * @param string $filename
  * @return Template
  */
 protected function getTemplate($filename)
 {
     $template = new Template($this->view, $filename);
     $template->set('app', $this->getAppGlobal());
     return $template;
 }