From 61b70f1b444ce746b6b290098dd6f86734eabbf8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Dec 2009 00:26:43 -0500 Subject: [PATCH] Removing parameters from RouterRoute::_writeRoute(). --- cake/libs/router.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 5c0117ea1d9..44a0c0e568c 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1219,42 +1219,40 @@ function compile() { 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 . '>[^/]+))?';