From 344f49e1bf92486efda131758db3bf727885348a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 31 Jul 2011 17:40:03 -0500 Subject: [PATCH] made router routes optional and fixed front controller. --- public/index.php | 4 +--- system/routing/router.php | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/public/index.php b/public/index.php index e81191a0..0f477cc7 100644 --- a/public/index.php +++ b/public/index.php @@ -145,9 +145,7 @@ // ---------------------------------------------------------- if (is_null($response)) { - list($method, $uri) = array(System\Request::method(), System\Request::uri()); - - $route = System\Routing\Router::make($method, $uri, System\Routing\Loader::load($uri))->route(); + $route = System\Routing\Router::make(Request::method(), Request::uri())->route(); $response = (is_null($route)) ? System\Response::make(System\View::make('error/404'), 404) : $route->call(); } diff --git a/system/routing/router.php b/system/routing/router.php index 29f83d93..bfabc18d 100644 --- a/system/routing/router.php +++ b/system/routing/router.php @@ -26,12 +26,13 @@ class Router { * @param array $routes * @return void */ - public function __construct($method, $uri, $routes) + public function __construct($method, $uri, $routes = null) { // Put the request method and URI in route form. Routes begin with // the request method and a forward slash. $this->request = $method.' /'.trim($uri, '/'); - $this->routes = $routes; + + $this->routes = (is_null($routes)) ? Loader::load($uri) : $routes; } /**