Esempio n. 1
0
 public function dispatch()
 {
     try {
         $controller = Router::Router()->getController();
         $action = Router::Router()->getAction();
         if ($controller->preRunFunction) {
             call_user_func([$controller, $controller->preRunFunction]);
         }
         if ($controller->canRespondToAction($action)) {
             call_user_func([$controller, $action]);
         } else {
             (new Error())->Action404();
         }
     } catch (Exception $e) {
         $c = new Error();
         $c->setException($e);
         $c->Action500();
     }
 }
Esempio n. 2
0
 private function find($name)
 {
     $controller = Router::Router()->getController()->getName();
     if ($controller) {
         // First, try controller path.
         $path = ROOT . "views/{$controller}/{$name}.tpl";
         if (file_exists($path)) {
             return $path;
         } else {
             if (strpos($name, '/') !== false) {
                 // trying to do cross-controller viewing, which is
                 // bad design.
                 throw new Exception("Unable to locate nested view '{$name}' in view layer.");
             }
         }
     }
     $stdPath = ROOT . 'views/' . $name . '.tpl';
     if (file_exists($stdPath)) {
         return $stdPath;
     }
     throw new Exception("Unable to locate view '{$name}' in view layer.");
 }
Esempio n. 3
0
<?php

namespace Zule;

use Zule\Tools\Router;
use Zule\Controllers\Error;
use Exception;
require_once '../tools/Main.php';
try {
    $controller = Router::Router()->getController();
    $action = Router::Router()->getAction();
    if ($controller->preRunFunction) {
        call_user_func([$controller, $controller->preRunFunction]);
    }
    if ($controller->canRespondToAction($action)) {
        call_user_func([$controller, $action]);
    } else {
        (new Error())->Action404();
    }
} catch (Exception $e) {
    $c = new Error();
    $c->setException($e);
    $c->Action500();
}
Esempio n. 4
0
 public function __construct()
 {
     parent::__construct('Error', Router::Router());
 }