Пример #1
0
 public function run($route)
 {
     $controllerClass = new Controller();
     $templateClass = new Template();
     if ($this->resolveRoute($route)) {
         $controller = $this->controllerNamespace . DS . $this->controller;
         $response = call_user_func_array(array(new $controller(), $this->method), $this->params);
         if ($controllerClass->hasView == false && $response === null) {
             //run default view related to class and method
             return $controllerClass->view($this->controller . '/' . $this->method, $templateClass->getViewBag());
         }
         // elseif($response === null){
         //     throw new \Exception(sprintf('The controller %s must return a valid Response', $this->controller.'/'.$this->method));
         // }
         return $response;
     } else {
         throw new NotFoundException(sprintf('Route "%s/%s" not found', $this->controller, $this->method));
     }
 }
Пример #2
0
 function view($template = null, $params = array())
 {
     $contoller = new Controller();
     return $contoller->view($template, $params);
 }