removed route\loader and route\parser classes.

This commit is contained in:
Taylor Otwell 2011-07-07 22:55:27 -05:00
parent ad824341a6
commit 06cb63f502
2 changed files with 0 additions and 73 deletions

View File

@ -1,40 +0,0 @@
<?php namespace System\Route;
class Loader {
/**
* Load the route file based on the first segment of the URI.
*
* @param string $uri
* @return void
*/
public static function load($uri)
{
if ( ! is_dir(APP_PATH.'routes'))
{
return require APP_PATH.'routes'.EXT;
}
if ( ! file_exists(APP_PATH.'routes/home'.EXT))
{
throw new \Exception("A [home] route file is required when using a route directory.");
}
if ($uri == '/')
{
return require APP_PATH.'routes/home'.EXT;
}
else
{
$segments = explode('/', trim($uri, '/'));
if ( ! file_exists(APP_PATH.'routes/'.$segments[0].EXT))
{
return require APP_PATH.'routes/home'.EXT;
}
return array_merge(require APP_PATH.'routes/'.$segments[0].EXT, require APP_PATH.'routes/home'.EXT);
}
}
}

View File

@ -1,33 +0,0 @@
<?php namespace System\Route;
class Parser {
/**
* Get the parameters that should be passed to the route callback.
*
* @param string $uri
* @param string $route
* @return array
*/
public static function parameters($uri, $route)
{
$parameters = array();
$uri_segments = explode('/', $uri);
$route_segments = explode('/', $route);
// --------------------------------------------------------------
// Any route segment wrapped in parentheses is a parameter.
// --------------------------------------------------------------
for ($i = 0; $i < count($route_segments); $i++)
{
if (strpos($route_segments[$i], '(') === 0)
{
$parameters[] = $uri_segments[$i];
}
}
return $parameters;
}
}