Matches any routes that may exist in the config/routes.php file
against the URI to determine if the class/method need to be remapped.
protected _parse_routes ( ) : void | ||
Результат | void |
/** * set routes to lowercaser * @return string routes */ public function _parse_routes() { foreach ($this->uri->segments as &$segment) { $segment = strtolower($segment); } return parent::_parse_routes(); }
/** * {inheritdoc} */ protected function _parse_routes() { // Apply the current module's routing config foreach ($this->module->getList('module') as $module) { $mod_path = $this->module->getPath($module->name); if (file_exists($mod_path . 'config/routes.php')) { include $mod_path . 'config/routes.php'; $route = (!isset($route) or !is_array($route)) ? [] : $route; $this->routes = array_merge($route, $this->routes); unset($route); } } // Let parent do the heavy routing return parent::_parse_routes(); }
function _parse_routes() { // Apply the current module's routing config if ($module = $this->uri->segment(0)) { foreach ($this->config->item('modules_locations') as $location) { if (is_file($file = $location . $module . '/config/routes.php')) { include $file; $route = (!isset($route) or !is_array($route)) ? array() : $route; $this->routes = array_merge($this->routes, $route); unset($route); } } } //使用默认 return parent::_parse_routes(); }
function _parse_routes() { $rest_routes = map_resources(); // we do this for performence if (empty($rest_routes) && count($this->routes) == 1) { $this->_set_request($this->uri->segments); return; } // also this... $uri = implode('/', $this->uri->segments); if (isset($this->routes[$uri])) { $this->_set_request(explode('/', $this->routes[$uri])); return; } // RESTful url matching... $request_method = $_SERVER['REQUEST_METHOD']; $routes = isset($rest_routes[$request_method]) && $rest_routes[$request_method] ? $rest_routes[$request_method] : array(); foreach ($routes as $pattern => $replace) { $pattern = str_replace(':id', '[^/]+', $pattern); // use this to match non-numeric id field $pattern = str_replace(':any', '.+', $pattern); $pattern = str_replace(':num', '[0-9]+', $pattern); $pattern = str_replace(':uuid', '[a-zA-Z0-9]{8}(-[a-zA-Z0-9]{4}){3}-[a-zA-Z0-9]{12}', $pattern); // Does the RegEx match? if (preg_match("#^{$pattern}\$#", $uri)) { // Do we have a back-reference? if (strpos($replace, '$') !== FALSE && strpos($pattern, '(') !== FALSE) { $replace = preg_replace("#^{$pattern}\$#", $replace, $uri); } // we are done $this->_set_request(explode('/', $replace)); return; } } // if non of the rules match, then go on... parent::_parse_routes(); }
/** * Parse Routes * * This function matches any routes that may exist in * the config/routes.php file against the URI to * determine if the class/method need to be remapped. * * NOTE: The first segment must stay the name of the * module, otherwise it is impossible to detect * the current module in this method. * * @access private * @return void */ function _parse_routes() { // Apply the current module's routing config // CI v3.x has URI starting at segment 1 $segstart = intval(substr(CI_VERSION, 0, 1)) > 2 ? 1 : 0; if ($module = $this->uri->segment($segstart)) { foreach ($this->config->item('modules_locations') as $location) { if (is_file($file = $location . $module . '/config/routes.php')) { include $file; $route = (!isset($route) or !is_array($route)) ? array() : $route; $this->routes = array_merge($this->routes, $route); unset($route); } } } // Let parent do the heavy routing return parent::_parse_routes(); }
/** * Parse routes, appending aditional bundle routes * * @return void */ protected function _parse_routes() { if ($bundle_path = $this->bundle->get_active_path()) { if (file_exists($bundle_path . 'config/routes.php')) { include $bundle_path . 'config/routes.php'; } // Validate & get reserved routes if (isset($route) && is_array($route)) { $this->routes = array_merge($route, $this->bundle->get_routes(), $this->routes); } } parent::_parse_routes(); }
/** * * @see Page * @see Page::setup() * @see CI_Router * @see CI_Router::_parse_routes() * @access public */ public function _parse_routes() { require_once APPPATH . '/libraries/Page.php'; Page::setup($this->uri->segments); parent::_parse_routes(); }