示例#1
0
 public function runMethod($params, $method = null)
 {
     $path = $method === null ? $this->method : $method;
     if (method_exists($this, $path)) {
         $controllerClass = new ReflectionClass($this->getName());
         $method = $controllerClass->GetMethod($path);
         if ($this->view->template == null) {
             $this->view->template = str_replace("/", "_", $this->route) . '_' . $this->getRawMethod() . '.tpl.php';
         }
         $method->invokeArgs($this, $params);
         $this->preRender();
         $return = $this->view->out($this->getData());
         $return = $this->postRender($return);
     } else {
         foreach ($this->componentInstances as $component) {
             //@todo Look at how to prevent this from running several times
             if ($component->hasMethod($path)) {
                 $component->variables = $this->variables;
                 $component->runMethod($params, $path);
                 break;
             }
         }
     }
     if ($this->view->cacheTimeout !== false && Ntentan::$debug !== true) {
         Cache::add('view_' . Ntentan::getRouteKey(), $return, $this->view->cacheTimeout);
     }
     echo $return;
 }