moved all routing classes into routing namespace.

This commit is contained in:
Taylor Otwell
2011-07-31 14:48:17 -05:00
parent d8eba6389c
commit 2275c74660
7 changed files with 53 additions and 43 deletions

33
system/routing/loader.php Normal file
View File

@@ -0,0 +1,33 @@
<?php namespace System\Routing;
class Loader {
/**
* Load the appropriate routes for the request URI.
*
* @param string
* @return array
*/
public static function load($uri)
{
$base = require APP_PATH.'routes'.EXT;
if ( ! is_dir(APP_PATH.'routes') or $uri == '')
{
return $base;
}
list($routes, $segments) = array(array(), explode('/', $uri));
foreach (array_reverse($segments, true) as $key => $value)
{
if (file_exists($path = ROUTE_PATH.implode('/', array_slice($segments, 0, $key + 1)).EXT))
{
$routes = require $path;
}
}
return array_merge($routes, $base);
}
}