Jelix\Routing\ClientRequest::getModuleAction PHP Method

getModuleAction() public method

retrieve module and action fills also $module and $action properties
public getModuleAction ( )
    public function getModuleAction()
    {
        $conf = App::config();
        if (isset($this->params['module']) && trim($this->params['module']) != '') {
            $this->module = $this->params['module'];
        } else {
            $this->module = 'main';
        }
        if (isset($this->params['action']) && trim($this->params['action']) != '') {
            $this->action = $this->params['action'];
        } else {
            $this->action = 'default:index';
        }
        return array($this->module, $this->action);
    }

Usage Example

Esempio n. 1
0
 /**
  * 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);
     }
 }