Exemple #1
0
 static function popCurrentModule()
 {
     return \Jelix\Core\App::popCurrentModule();
 }
Exemple #2
0
 /**
  * main method : launch the execution of the action.
  *
  * This method should be called in a entry point.
  *
  * @param  ClientRequest  $request the request object. It is required if a descendant of Router 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 = App::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;
         }
     }
     App::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;
                 App::popCurrentModule();
                 App::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();
     }
     App::popCurrentModule();
     \jSession::end();
 }