/**
  * load a Controller 
  * @param  Request $request the client request
  * @return mixed a Controller
  */
 static function load()
 {
     $request = Request::getInstance();
     $fileName = Config::controllerDIR() . DS . $request->controller . 'Controller.php';
     if (!file_exists($fileName)) {
         throw new \Exception("Controller {$request->controller} does not exist", 101);
     }
     require $fileName;
     $name = $request->namespace . '\\Controller\\' . $request->controller . 'Controller';
     return new $name();
 }
示例#2
0
 public function __construct()
 {
     try {
         Session::start();
         Config::getConf();
         $this->request = Request::getInstance();
         $this->router = new Router($this->request);
         $this->request->setRouter($this->router);
         $this->controller = MasterController::load();
     } catch (\Exception $e) {
         $this->controller = new ErrorController($e);
         //c'est fait
     }
 }
示例#3
0
 /**
  * construct
  * @param Exception $exception the exception
  */
 public function __construct($exception)
 {
     $this->request = Request::getInstance();
     $save['controller'] = $this->request->controller;
     $this->request->controller = 'ErrorController';
     $save['action'] = $this->request->action;
     if (Config::getDebug()) {
         $this->request->action = 'error';
     } else {
         $this->request->action = 'error404';
     }
     $this->request->params = ['error' => $exception];
     $this->view = new MasterView();
     $this->view->set($save);
     $this->view->layout = 'error';
     $this->loadTools();
     $this->execute();
 }
示例#4
0
 function __construct()
 {
     $this->request = Request::getInstance();
 }