Created
June 17, 2011 13:15
-
-
Save kemo/1031396 to your computer and use it in GitHub Desktop.
Request::process_uri()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Process URI | |
* | |
* @param string $uri URI | |
* @param array $routes Route | |
* @return array | |
*/ | |
public static function process_uri($uri, $routes = NULL) | |
{ | |
// Load routes | |
$routes = (empty($routes)) ? Route::all() : $routes; | |
$params = NULL; | |
foreach ($routes as $name => $route) | |
{ | |
// We found something suitable | |
if ($params = $route->matches($uri)) | |
{ | |
return array( | |
'params' => $params, | |
'route' => $route, | |
); | |
} | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment