Ejemplo n.º 1
0
Archivo: App.php Proyecto: NePTeR/sonic
 /**
  * runs a controller and action combination
  *
  * @param string $controller_name controller to use
  * @param string $action method within controller to execute
  * @param array $args arguments to be added to the Request object and view
  * @param bool $json should we render json
  * @param string $id view id for if we are in turbo mode an exception is thrown
  * @return void
  */
 protected function _runController($controller_name, $action, $args = array(), $json = false, $id = null)
 {
     $this->getRequest()->addParams($args);
     $controller = $this->getController($controller_name);
     $controller->setView($action, false);
     // if we are requesting JSON that means this is being processed from the turbo queue
     // if we are not in turbo mode then we run the action normally
     $can_run = $json || !$this->getSetting(self::TURBO);
     if ($this->_delegate) {
         $this->_delegate->actionWasCalled($controller, $action);
     }
     if ($can_run) {
         $this->_runAction($controller, $action);
     }
     $view = null;
     if ($controller->hasView()) {
         $view = $controller->getView();
         $view->setAction($action);
         $view->addVars($args);
     }
     // process the layout if we can
     // this takes care of handling this view
     if ($this->_processLayout($controller, $view, $args)) {
         return;
     }
     if (!$view) {
         return;
     }
     if ($this->_delegate) {
         $this->_delegate->viewStartedRendering($view, $json);
     }
     // output the view contents
     $view->output($json, $id);
     if ($this->_delegate) {
         $this->_delegate->viewFinishedRendering($view, $json);
     }
 }