Example #1
0
 public function __construct()
 {
     $this->_session = Session::getInstance();
     $this->_input = InputData::getInstance();
 }
 /**
  * @throws \Exception
  */
 private function loadRoute()
 {
     $file = $this->controller . 'Controller';
     $input = InputData::getInstance();
     $input->setPost($this->router->getPost());
     if (!class_exists($file)) {
         throw new \Exception('Class ' . $file . ' not found.', 404);
     }
     if (!method_exists($file, $this->method)) {
         throw new \Exception('Method ' . $this->method . ' not found in class ' . $file . '.', 404);
     }
     $newController = new $file();
     $method = new ReflectionMethod($newController, $this->method);
     $annotations = $method->getDocComment();
     foreach ($method->getParameters() as $param) {
         $param = $param->getClass()->name;
         if (class_exists($param)) {
             $this->params[] = new $param();
         }
     }
     Annotations::getInstance($annotations);
     call_user_func_array(array($newController, $this->method), $this->params);
 }