/** * Convert a request path string into routing params */ public function parse() { $this->resetActions(); $this->resetParams(); $this->setArea($this->_default_area); $this->setController($this->_default_controller); $this->addAction('init-action', false); $path = Utils::getValue($this->_path_request, '/'); $path = Sanitize::toPath(@parse_url($path, PHP_URL_PATH)); $path = str_replace(Server::getBasePath(), '', $path); $route = explode('/', trim($path, '/')); if (!empty($route[0]) && $this->areaExists($route[0])) { $this->setArea(array_shift($route)); } if (!empty($route[0])) { $this->setController(array_shift($route)); } if (!empty($route[0])) { $this->addAction(array_shift($route)); } if (!empty($route)) { $this->_params = array_values($route); } if (count($this->_actions) === 1) { $this->addAction($this->_default_action); } }