changed Request::is to Request::route_is.

This commit is contained in:
Taylor Otwell 2011-06-19 22:49:01 -05:00
parent 2b4093f7a5
commit dbc418c0d7
2 changed files with 16 additions and 16 deletions

View File

@ -74,17 +74,6 @@ public static function uri()
return ($uri == '') ? '/' : Str::lower($uri); return ($uri == '') ? '/' : Str::lower($uri);
} }
/**
* Determine if the route handling the request is a given name.
*
* @param string $name
* @return bool
*/
public static function is($name)
{
return (is_array(static::$route->callback) and isset(static::$route->callback['name']) and static::$route->callback['name'] === $name);
}
/** /**
* Get the request method. * Get the request method.
* *
@ -125,7 +114,7 @@ public static function ip()
* *
* @return bool * @return bool
*/ */
public static function secure() public static function is_secure()
{ {
return (static::protocol() == 'https'); return (static::protocol() == 'https');
} }
@ -145,11 +134,22 @@ public static function protocol()
* *
* @return bool * @return bool
*/ */
public static function ajax() public static function is_ajax()
{ {
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and Str::lower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'); return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and Str::lower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
} }
/**
* Determine if the route handling the request is a given name.
*
* @param string $name
* @return bool
*/
public static function route_is($name)
{
return (is_array(static::$route->callback) and isset(static::$route->callback['name']) and static::$route->callback['name'] === $name);
}
/** /**
* Magic Method to handle dynamic static methods. * Magic Method to handle dynamic static methods.
*/ */
@ -160,9 +160,9 @@ public static function __callStatic($method, $parameters)
// //
// Example: Request::is_login() // Example: Request::is_login()
// -------------------------------------------------------------- // --------------------------------------------------------------
if (strpos($method, 'is_') === 0) if (strpos($method, 'route_is_') === 0)
{ {
return static::is(substr($method, 3)); return static::route_is(substr($method, 9));
} }
} }

View File

@ -56,7 +56,7 @@ public static function route($method, $uri)
if (preg_match('#^'.$key.'$#', $method.' '.$uri)) if (preg_match('#^'.$key.'$#', $method.' '.$uri))
{ {
return Request::$route = new Route($key, $callback, Route\Parser::parameters($uri, $key)); return Request::$route = new Route($keys, $callback, Route\Parser::parameters($uri, $key));
} }
} }
} }