From c95e7fdbbe0ab69b1dd74b3fbd8b43ba58c0fba1 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 11 Jul 2011 13:38:07 -0700 Subject: [PATCH] Refactor router to use routes.php as the default routes for all requests, even when using a routes directory. --- system/router.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/system/router.php b/system/router.php index 97dc0830..86715ece 100644 --- a/system/router.php +++ b/system/router.php @@ -58,7 +58,9 @@ public static function route($method, $uri) */ public static function load($uri) { - return (is_dir(APP_PATH.'routes')) ? static::load_from_directory($uri) : require APP_PATH.'routes'.EXT; + $base = require APP_PATH.'routes'.EXT; + + return (is_dir(APP_PATH.'routes') and $uri !== '') ? array_merge(static::load_from_directory($uri), $base) : $base; } /** @@ -69,18 +71,9 @@ public static function load($uri) */ private static function load_from_directory($uri) { - // If it exists, The "home" routes file is loaded for every request. This allows - // for "catch-all" routes such as http://example.com/username... - $home = (file_exists($path = APP_PATH.'routes/home'.EXT)) ? require $path : array(); - - if ($uri == '') - { - return $home; - } - $segments = explode('/', $uri); - return (file_exists($path = APP_PATH.'routes/'.$segments[0].EXT)) ? array_merge(require $path, $home) : $home; + return (file_exists($path = APP_PATH.'routes/'.$segments[0].EXT)) ? require $path : array(); } /**