Improve comments in Route\Finder.
This commit is contained in:
parent
7ce9c6f270
commit
ad3f98db6b
|
@ -24,31 +24,23 @@ class Finder {
|
||||||
*/
|
*/
|
||||||
public static function find($name)
|
public static function find($name)
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------
|
|
||||||
// Load the routes if we haven't already.
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
if (is_null(static::$routes))
|
if (is_null(static::$routes))
|
||||||
{
|
{
|
||||||
static::$routes = (is_dir(APP_PATH.'routes')) ? static::load() : require APP_PATH.'routes'.EXT;
|
static::$routes = (is_dir(APP_PATH.'routes')) ? static::load() : require APP_PATH.'routes'.EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
// Have we already located this route by name?
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
if (array_key_exists($name, static::$names))
|
if (array_key_exists($name, static::$names))
|
||||||
{
|
{
|
||||||
return static::$names[$name];
|
return static::$names[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// Instantiate the SPL array iterators.
|
// We haven't located the route before, so we'll need to
|
||||||
// --------------------------------------------------------------
|
// iterate through each route to find the matching name.
|
||||||
|
// ---------------------------------------------------------
|
||||||
$arrayIterator = new \RecursiveArrayIterator(static::$routes);
|
$arrayIterator = new \RecursiveArrayIterator(static::$routes);
|
||||||
$recursiveIterator = new \RecursiveIteratorIterator($arrayIterator);
|
$recursiveIterator = new \RecursiveIteratorIterator($arrayIterator);
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
// Iterate over the routes and find the named route.
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
foreach ($recursiveIterator as $iterator)
|
foreach ($recursiveIterator as $iterator)
|
||||||
{
|
{
|
||||||
$route = $recursiveIterator->getSubIterator();
|
$route = $recursiveIterator->getSubIterator();
|
||||||
|
@ -63,15 +55,15 @@ public static function find($name)
|
||||||
/**
|
/**
|
||||||
* Load all of the routes from the routes directory.
|
* Load all of the routes from the routes directory.
|
||||||
*
|
*
|
||||||
|
* All of the various route files will be merged together
|
||||||
|
* into a single array that can be searched.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function load()
|
private static function load()
|
||||||
{
|
{
|
||||||
$routes = array();
|
$routes = array();
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
// Merge all of the various route files together.
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
foreach (glob(APP_PATH.'routes/*') as $file)
|
foreach (glob(APP_PATH.'routes/*') as $file)
|
||||||
{
|
{
|
||||||
if (filetype($file) == 'file')
|
if (filetype($file) == 'file')
|
||||||
|
|
Loading…
Reference in New Issue