Beispiel #1
0
 /**
  * Transfer the process to other action or controller
  *
  * @param string $action Action key you want to transfer
  * @param string $controller Controller key you want to transfer
  * @return void
  */
 public function transfer($action, $controller = null)
 {
     if ($controller != null) {
         $this->view->setRenderingController($controller);
     }
     $this->view->setRenderingAction($action);
     $actionMethod = NameManager::convertActionToMethod($action);
     if ($controller == null) {
         $this->{$actionMethod}();
     } else {
         $subdir = '';
         $parts = explode('/', trim($controller, '/'));
         $partsCnt = count($parts);
         if ($partsCnt > 1) {
             $controller = $parts[$partsCnt - 1];
             unset($parts[$partsCnt - 1]);
             $subdir = implode('/', $parts);
         }
         $className = NameManager::convertControllerToClass($controller);
         $ins = Loader::getControllerInstance($className, $subdir);
         $ins->setRequest($this->request);
         $ins->setView($this->view);
         $ins->{$actionMethod}();
     }
     $this->dispatched = true;
 }