mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing parameters from RouterRoute::_writeRoute().
This commit is contained in:
parent
494875cca2
commit
61b70f1b44
1 changed files with 11 additions and 13 deletions
|
@ -1219,42 +1219,40 @@ class RouterRoute {
|
|||
if ($this->compiled()) {
|
||||
return $this->_compiledRoute;
|
||||
}
|
||||
$this->_writeRoute($this->template, $this->defaults, $this->options);
|
||||
$this->_writeRoute();
|
||||
return $this->_compiledRoute;
|
||||
}
|
||||
/**
|
||||
* Builds a route regular expression
|
||||
* Builds a route regular expression. Uses the template, defaults and options
|
||||
* properties to compile a regular expression that can be used to match/parse request strings.
|
||||
*
|
||||
* @param string $route An empty string, or a route string "/"
|
||||
* @param array $default NULL or an array describing the default route
|
||||
* @param array $params An array matching the named elements in the route to regular expressions
|
||||
* which that element should match.
|
||||
* @return void
|
||||
* @access protected
|
||||
*/
|
||||
function _writeRoute($route, $default, $params) {
|
||||
if (empty($route) || ($route === '/')) {
|
||||
function _writeRoute() {
|
||||
if (empty($this->template) || ($this->template === '/')) {
|
||||
$this->_compiledRoute = '#^/*$#';
|
||||
$this->keys = array();
|
||||
return;
|
||||
}
|
||||
$route = $this->template;
|
||||
$names = $replacements = $search = array();
|
||||
$parsed = preg_quote($route, '#');
|
||||
$parsed = preg_quote($this->template, '#');
|
||||
|
||||
preg_match_all('#:([A-Za-z0-9_-]+[A-Z0-9a-z])#', $route, $namedElements);
|
||||
foreach ($namedElements[1] as $i => $name) {
|
||||
if (isset($params[$name])) {
|
||||
if (isset($this->options[$name])) {
|
||||
$option = null;
|
||||
if ($name !== 'plugin' && array_key_exists($name, $default)) {
|
||||
if ($name !== 'plugin' && array_key_exists($name, $this->defaults)) {
|
||||
$option = '?';
|
||||
}
|
||||
$slashParam = '/\\' . $namedElements[0][$i];
|
||||
if (strpos($parsed, $slashParam) !== false) {
|
||||
$replacements[] = '(?:/(?P<' . $name . '>' . $params[$name] . ')' . $option . ')' . $option;
|
||||
$replacements[] = '(?:/(?P<' . $name . '>' . $this->options[$name] . ')' . $option . ')' . $option;
|
||||
$search[] = $slashParam;
|
||||
} else {
|
||||
$search[] = '\\' . $namedElements[0][$i];
|
||||
$replacements[] = '(?:(?P<' . $name . '>' . $params[$name] . ')' . $option . ')' . $option;
|
||||
$replacements[] = '(?:(?P<' . $name . '>' . $this->options[$name] . ')' . $option . ')' . $option;
|
||||
}
|
||||
} else {
|
||||
$replacements[] = '(?:(?P<' . $name . '>[^/]+))?';
|
||||
|
|
Loading…
Reference in a new issue