moved all routing classes into routing namespace.
This commit is contained in:
33
system/routing/loader.php
Normal file
33
system/routing/loader.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user