added dynamic Request::is_ method.. e.g. Request::is_login().

This commit is contained in:
Taylor Otwell
2011-06-18 12:00:52 -05:00
parent 7f06e0f4cd
commit a3a9368707
3 changed files with 56 additions and 38 deletions

View File

@@ -33,7 +33,7 @@ class Router {
// --------------------------------------------------------------
if (isset(static::$routes[$method.' '.$uri]))
{
return new Route(static::$routes[$method.' '.$uri]);
return Request::$route = new Route($method.' '.$uri, static::$routes[$method.' '.$uri]);
}
// --------------------------------------------------------------
@@ -50,13 +50,13 @@ class Router {
// --------------------------------------------------------------
// Routes can be comma-delimited, so spin through each one.
// --------------------------------------------------------------
foreach (explode(', ', $keys) as $route)
foreach (explode(', ', $keys) as $key)
{
$route = str_replace(':num', '[0-9]+', str_replace(':any', '[a-zA-Z0-9\-_]+', $route));
$key = str_replace(':num', '[0-9]+', str_replace(':any', '[a-zA-Z0-9\-_]+', $key));
if (preg_match('#^'.$route.'$#', $method.' '.$uri))
if (preg_match('#^'.$key.'$#', $method.' '.$uri))
{
return new Route($callback, Route\Parser::parameters($uri, $route));
return Request::$route = new Route($key, $callback, Route\Parser::parameters($uri, $key));
}
}
}