예제 #1
0
 /**
  * concrete request & response
  */
 public function dispatch()
 {
     $target_module = $this->_request->getContextAttr('module');
     $target_ctrl = $this->_request->getContextAttr('ctrl');
     $target_act = $this->_request->getContextAttr('act');
     if (!$target_module || !$target_act || !$target_ctrl) {
         return false;
     }
     // firstly we must confirm the ctrl is reachable
     $EXEC = Executor::getInstance();
     $moduleDir = $EXEC->getModuleDir();
     $moduleDir = rtrim($moduleDir, '/\\');
     $initFileNamePost = $EXEC->getModuleInitFileName();
     $moduleInitFile = $moduleDir . '/Module' . $initFileNamePost;
     $this->importFileByAbsPath($moduleInitFile);
     $mvcInitFile = $moduleDir . '/' . $target_module . '/' . ucfirst($target_module) . $initFileNamePost;
     $this->importFileByAbsPath($mvcInitFile);
     $moduleBaseNamespace = ltrim(str_replace(APPLICATION_PATH, '', $moduleDir), '/\\');
     $tmp = $moduleBaseNamespace ? $moduleBaseNamespace . '\\' : '';
     $ctrlClassBaseName = $target_ctrl . $EXEC->getCtrlClassPostfix();
     $mvcCtrlClassName = 'application\\' . $tmp . $target_module . '\\ctrl\\' . $ctrlClassBaseName;
     $actPostFix = $EXEC->getActMethodPostfix();
     $actMethodName = $target_act . $actPostFix;
     $actViewModel = null;
     try {
         $actViewModel = $this->executeAct($mvcCtrlClassName, $actMethodName);
     } catch (DispatchException $e) {
         // force to ErrorCtrl -> (indexAct) beneath the same dir
         $actViewModel = $this->handleMvcError(str_replace($ctrlClassBaseName, $EXEC->getErrorCtrlName() . $EXEC->getCtrlClassPostfix(), $mvcCtrlClassName), $EXEC->getErrorActName() . $actPostFix, $e);
     }
     // plugin init
     // Dispatch
     // plugin terminate
 }