Ejemplo n.º 1
0
 /**
  * Renders a exception/error template
  *
  * @param array $args
  */
 protected static final function renderException($args)
 {
     Buffer::clear(true);
     /**
      * Set header status code
      */
     Header::set(500, false);
     /**
      * Reset all to the default
      */
     $activeProject = ProjectManager::getActiveProject();
     if ($activeProject) {
         $activeProject->setActive(false);
     }
     Locale::set(DEFAULT_LOCALE);
     /**
      * Render with the exception layout
      */
     self::renderTemplate(EXCEPTION_LAYOUT, $args, true);
     exit;
 }
Ejemplo n.º 2
0
 /**
  * @return string
  */
 public function getErrorMessage()
 {
     return Header::getStatusMessage();
 }
Ejemplo n.º 3
0
 /**
  * Renders a view and returns the content
  * A optional view if possible. If no view is
  * given. The view of the layout will be
  * taken.
  *
  * @param  string $viewPath
  */
 public function renderView($viewPath = '')
 {
     // Get current layout
     $template = Template::getInstance();
     $view = $template->getView();
     $layout = $template->getLayout();
     if (empty($viewPath)) {
         if (!$view->isRouteActive()) {
             // Get view and action
             $file = $view->getPath();
             if (is_string($this->controller)) {
                 // Output rendered html from the return of the controller
                 echo $this->controller;
             } else {
                 if (!file_exists($file)) {
                     $view->viewNotFound();
                 }
                 // Output rendered html (view)
                 echo $this->getRenderedHtml($file);
             }
         } else {
             if (is_string($this->controller)) {
                 echo $this->controller;
             } else {
                 $file = $view->getPath();
                 if (!empty($file)) {
                     if (!file_exists($file)) {
                         $view->viewNotFound();
                     } else {
                         // Output view
                         echo $this->getRenderedHtml($file);
                     }
                 } else {
                     echo '';
                 }
             }
         }
     } else {
         $file = PathHelper::getRealViewPath($viewPath, '', $layout->getName());
         if (file_exists($file)) {
             $file = $this->getRenderedHtml($file);
         } else {
             HttpHeader::set(404);
         }
         return $file;
     }
 }
Ejemplo n.º 4
0
 /**
  * Throws a 404 error and a exception
  * which defines this error
  */
 public function viewNotFound()
 {
     HttpHeader::set(404, false);
     throw new View\Exception\ViewNotFoundException('The view "' . $this->getPath() . '" was not found.');
 }