/** * initialize the given request and some properties of the router * * It extracts information for the request to set the module name and the * action name. It doesn't verify if the corresponding controller does * exist or not. * It enables also the error handler of Jelix, if needed. * Does not call this method directly in entry points. Prefer to call * process() instead (that will call setRequest). * setRequest is mostly used for tests or specific contexts. * @param ClientRequest $request the request object * @throw \jException if the module is unknown or the action name format is not valid * @see Router::process() */ protected function setRequest($request) { $config = App::config(); $this->request = $request; if ($config->enableErrorHandler) { set_error_handler(array($this, 'errorHandler')); set_exception_handler(array($this, 'exceptionHandler')); // let's log messages appeared during init foreach (\jBasicErrorHandler::$initErrorMessages as $msg) { \Jelix\Logger\Log::log($msg, $msg->getCategory()); } } $this->request->init(); list($this->moduleName, $this->actionName) = $request->getModuleAction(); App::pushCurrentModule($this->moduleName); $this->action = $this->originalAction = new \jSelectorActFast($this->request->type, $this->moduleName, $this->actionName); if ($config->modules[$this->moduleName . '.access'] < 2) { throw new \jException('jelix~errors.module.untrusted', $this->moduleName); } }