Permalink
Browse files

Removing parameters from RouterRoute::_writeRoute().

  • Loading branch information...
1 parent 494875c commit 61b70f1b444ce746b6b290098dd6f86734eabbf8 @markstory markstory committed Dec 2, 2009
Showing with 11 additions and 13 deletions.
  1. +11 −13 cake/libs/router.php
View
@@ -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 . '>[^/]+))?';

0 comments on commit 61b70f1

Please sign in to comment.