added better comments to url->to_route method.

This commit is contained in:
Taylor Otwell 2011-09-20 00:11:38 -05:00
parent 096280c958
commit 1463617f13
1 changed files with 4 additions and 0 deletions

View File

@ -146,11 +146,15 @@ public function to_route($name, $parameters = array(), $https = false)
$uri = substr($uris[0], strpos($uris[0], '/')); $uri = substr($uris[0], strpos($uris[0], '/'));
// Spin through each route parameter and replace the route wildcard segment
// with the corresponding parameter passed to the method.
foreach ($parameters as $parameter) foreach ($parameters as $parameter)
{ {
$uri = preg_replace('/\(.+?\)/', $parameter, $uri, 1); $uri = preg_replace('/\(.+?\)/', $parameter, $uri, 1);
} }
// Before generating the route URL, we will replace all remaining optional
// wildcard segments that were not replaced by parameters with spaces.
return $this->to(str_replace(array('/(:any?)', '/(:num?)'), '', $uri), $https); return $this->to(str_replace(array('/(:any?)', '/(:num?)'), '', $uri), $https);
} }