コード例 #1
0
 /**
  * main method : launch the execution of the action.
  *
  * This method should be called in a entry point.
  *
  * @param  jRequest  $request the request object. It is required if a descendant of jCoordinator did not called setRequest before
  */
 public function process($request = null)
 {
     jLog::log("process: start");
     try {
         if ($request) {
             $this->setRequest($request);
         }
         jSession::start();
         $ctrl = $this->getController($this->action);
     } catch (jException $e) {
         $config = jApp::config();
         if ($config->urlengine['notfoundAct'] == '') {
             throw $e;
         }
         if (!jSession::isStarted()) {
             jSession::start();
         }
         try {
             jLog::log("Exception: get notfoundact ctrl (" . $config->urlengine['notfoundAct'] . ")");
             $this->action = new jSelectorAct($config->urlengine['notfoundAct']);
             $ctrl = $this->getController($this->action);
         } catch (jException $e2) {
             throw $e;
         }
     }
     jApp::pushCurrentModule($this->moduleName);
     if (count($this->plugins)) {
         $pluginparams = array();
         if (isset($ctrl->pluginParams['*'])) {
             $pluginparams = $ctrl->pluginParams['*'];
         }
         if (isset($ctrl->pluginParams[$this->action->method])) {
             $pluginparams = array_merge($pluginparams, $ctrl->pluginParams[$this->action->method]);
         }
         jLog::dump($pluginparams, "process: plugin params");
         foreach ($this->plugins as $name => $obj) {
             jLog::log("process: beforeAction on plugin {$name}");
             $result = $this->plugins[$name]->beforeAction($pluginparams);
             if ($result) {
                 $this->action = $result;
                 jApp::popCurrentModule();
                 jApp::pushCurrentModule($result->module);
                 jLog::log("process: beforeAction said to do internal redirect to " . $result->module . "~" . $result->resource);
                 $this->moduleName = $result->module;
                 $this->actionName = $result->resource;
                 $ctrl = $this->getController($this->action);
                 break;
             }
         }
     }
     jLog::log('process: call action');
     $this->response = $ctrl->{$this->action->method}();
     if ($this->response == null) {
         throw new jException('jelix~errors.response.missing', $this->action->toString());
     }
     jLog::log('process: response: ' . get_class($this->response));
     if (get_class($this->response) == 'jResponseRedirect') {
         jLog::log('process: redirection to ' . $this->response->action);
     } else {
         if (get_class($this->response) == 'jResponseRedirectUrl') {
             jLog::log('process: redirection to ' . $this->response->url);
         }
     }
     foreach ($this->plugins as $name => $obj) {
         jLog::log('process: beforeOutput on plugin ' . $name);
         $this->plugins[$name]->beforeOutput();
     }
     jLog::log('process: call response output');
     $this->response->output();
     foreach ($this->plugins as $name => $obj) {
         jLog::log('process: afterProcess on plugin ' . $name);
         $this->plugins[$name]->afterProcess();
     }
     jApp::popCurrentModule();
     jSession::end();
     jLog::log('process: end');
 }
コード例 #2
0
 /**
  * main method : launch the execution of the action.
  *
  * This method should be called in a entry point.
  *
  * @param  jRequest  $request the request object. It is required if a descendant of jCoordinator did not called setRequest before
  */
 public function process($request = null)
 {
     try {
         if ($request) {
             $this->setRequest($request);
         }
         jSession::start();
         $ctrl = $this->getController($this->action);
     } catch (jException $e) {
         $config = jApp::config();
         if ($config->urlengine['notfoundAct'] == '') {
             throw $e;
         }
         if (!jSession::isStarted()) {
             jSession::start();
         }
         try {
             $this->action = new jSelectorAct($config->urlengine['notfoundAct']);
             $ctrl = $this->getController($this->action);
         } catch (jException $e2) {
             throw $e;
         }
     }
     jApp::pushCurrentModule($this->moduleName);
     if (count($this->plugins)) {
         $pluginparams = array();
         if (isset($ctrl->pluginParams['*'])) {
             $pluginparams = $ctrl->pluginParams['*'];
         }
         if (isset($ctrl->pluginParams[$this->action->method])) {
             $pluginparams = array_merge($pluginparams, $ctrl->pluginParams[$this->action->method]);
         }
         foreach ($this->plugins as $name => $obj) {
             $result = $this->plugins[$name]->beforeAction($pluginparams);
             if ($result) {
                 $this->action = $result;
                 jApp::popCurrentModule();
                 jApp::pushCurrentModule($result->module);
                 $this->moduleName = $result->module;
                 $this->actionName = $result->resource;
                 $ctrl = $this->getController($this->action);
                 break;
             }
         }
     }
     $this->response = $ctrl->{$this->action->method}();
     if ($this->response == null) {
         throw new jException('jelix~errors.response.missing', $this->action->toString());
     }
     foreach ($this->plugins as $name => $obj) {
         $this->plugins[$name]->beforeOutput();
     }
     $this->response->output();
     foreach ($this->plugins as $name => $obj) {
         $this->plugins[$name]->afterProcess();
     }
     jApp::popCurrentModule();
     jSession::end();
 }