refactoring.

This commit is contained in:
Taylor Otwell
2011-09-21 21:46:16 -05:00
parent b9b9711921
commit 0c4018ec88
42 changed files with 980 additions and 1330 deletions

View File

@@ -43,9 +43,6 @@ class Loader {
/**
* Load the applicable routes for a given URI.
*
* The application route directory will be checked for nested route files and an
* array of all applicable routes will be returned based on the URI segments.
*
* @param string $uri
* @return array
*/
@@ -80,9 +77,6 @@ class Loader {
/**
* Get every route defined for the application.
*
* For fast performance, if the routes have already been loaded once, they will not
* be loaded again, and the same routes will be returned on subsequent calls.
*
* @return array
*/
public function everything()

View File

@@ -67,13 +67,12 @@ class Router {
/**
* Search the routes for the route matching a request method and URI.
*
* If no route can be found, the application controllers will be searched.
*
* @param string $method
* @param string $uri
* @param Request $request
* @param string $method
* @param string $uri
* @return Route
*/
public function route($method, $uri)
public function route(Request $request, $method, $uri)
{
$routes = $this->loader->load($uri);
@@ -85,7 +84,7 @@ class Router {
// no need to spin through all of the routes.
if (isset($routes[$destination]))
{
return Request::$route = new Route($destination, $routes[$destination], array());
return $request->route = new Route($destination, $routes[$destination], array());
}
foreach ($routes as $keys => $callback)
@@ -101,20 +100,18 @@ class Router {
if (preg_match('#^'.$this->translate_wildcards($key).'$#', $destination))
{
return Request::$route = new Route($keys, $callback, $this->parameters($destination, $key));
return $request->route = new Route($keys, $callback, $this->parameters($destination, $key));
}
}
}
}
return Request::$route = $this->route_to_controller($method, $uri, $destination);
return $request->route = $this->route_to_controller($method, $uri, $destination);
}
/**
* Attempt to find a controller for the incoming request.
*
* If no corresponding controller can be found, NULL will be returned.
*
* @param string $method
* @param string $uri
* @param string $destination