Skip to content

Commit

Permalink
Renaming RouterRouter::$params to $options.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 2, 2009
1 parent 728613a commit 494875c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions cake/libs/router.php
Expand Up @@ -436,7 +436,7 @@ function parse($url) {
if (($r = $route->parse($url)) !== false) {
$self->__currentRoute[] =& $route;

$params = $route->params;
$params = $route->options;
$argOptions = array();

if (array_key_exists('named', $params)) {
Expand Down Expand Up @@ -762,7 +762,7 @@ function url($url = null, $full = false) {
for ($i = 0, $len = count($self->routes); $i < $len; $i++) {
$originalUrl = $url;

if (isset($self->routes[$i]->params['persist'], $params)) {
if (isset($self->routes[$i]->options['persist'], $params)) {
$url = $self->routes[$i]->persistParams($url, $params);
}

Expand Down Expand Up @@ -1150,7 +1150,7 @@ class RouterRoute {
*
* @var array
**/
var $params = array();
var $options = array();
/**
* Default parameters for a Route
*
Expand Down Expand Up @@ -1195,10 +1195,10 @@ class RouterRoute {
* @param string $params Array of parameters and additional options for the Route
* @return void
*/
function RouterRoute($template, $defaults = array(), $params = array()) {
function RouterRoute($template, $defaults = array(), $options = array()) {
$this->template = $template;
$this->defaults = (array)$defaults;
$this->params = (array)$params;
$this->options = (array)$options;
}
/**
* Check if a Route has been compiled into a regular expression.
Expand All @@ -1219,7 +1219,7 @@ function compile() {
if ($this->compiled()) {
return $this->_compiledRoute;
}
$this->_writeRoute($this->template, $this->defaults, $this->params);
$this->_writeRoute($this->template, $this->defaults, $this->options);
return $this->_compiledRoute;
}
/**
Expand Down Expand Up @@ -1334,7 +1334,7 @@ function parse($url) {
* @return array An array with persistent parameters applied.
*/
function persistParams($url, $params) {
foreach ($this->params['persist'] as $persistKey) {
foreach ($this->options['persist'] as $persistKey) {
if (array_key_exists($persistKey, $params)) {
$url[$persistKey] = $params[$persistKey];
}
Expand Down Expand Up @@ -1421,8 +1421,8 @@ function match($url) {
}

//check patterns for routed params
if (!empty($this->params)) {
foreach ($this->params as $key => $pattern) {
if (!empty($this->options)) {
foreach ($this->options as $key => $pattern) {
if (array_key_exists($key, $url) && !preg_match('#^' . $pattern . '$#', $url[$key])) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions cake/tests/cases/libs/router.test.php
Expand Up @@ -1986,7 +1986,7 @@ function testConstruction() {

$this->assertEqual($route->template, '/:controller/:action/:id');
$this->assertEqual($route->defaults, array());
$this->assertEqual($route->params, array('id' => '[0-9]+'));
$this->assertEqual($route->options, array('id' => '[0-9]+'));
$this->assertFalse($route->compiled());
}

Expand Down Expand Up @@ -2133,7 +2133,7 @@ function testComplexRouteCompilingAndParsing() {
$this->assertPattern($result, '/some_extra/page/this_is_the_slug');
$this->assertPattern($result, '/page/this_is_the_slug');
$this->assertEqual($route->keys, array('extra', 'slug'));
$this->assertEqual($route->params, array('extra' => '[a-z1-9_]*', 'slug' => '[a-z1-9_]+', 'action' => 'view'));
$this->assertEqual($route->options, array('extra' => '[a-z1-9_]*', 'slug' => '[a-z1-9_]+', 'action' => 'view'));
$expected = array(
'controller' => 'pages',
'action' => 'view',
Expand Down

0 comments on commit 494875c

Please sign in to comment.