From fb984016e81571e8b71a52fe3941ba9f5e5f41df Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 2 Aug 2011 22:19:13 -0500 Subject: [PATCH] added loader class. --- public/index.php | 21 ++------------ system/loader.php | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 system/loader.php diff --git a/public/index.php b/public/index.php index 6d9097a9..459e764a 100644 --- a/public/index.php +++ b/public/index.php @@ -67,31 +67,16 @@ // -------------------------------------------------------------- // Load the classes used by the auto-loader. // -------------------------------------------------------------- +require SYS_PATH.'loader'.EXT; require SYS_PATH.'config'.EXT; require SYS_PATH.'arr'.EXT; // -------------------------------------------------------------- // Register the auto-loader. // -------------------------------------------------------------- -spl_autoload_register(function($class) -{ - $file = strtolower(str_replace('\\', '/', $class)); +System\Loader::bootstrap(); - if (array_key_exists($class, $aliases = System\Config::get('aliases'))) - { - return class_alias($aliases[$class], $class); - } - - foreach (array(BASE_PATH, MODEL_PATH, LIBRARY_PATH) as $directory) - { - if (file_exists($path = $directory.$file.EXT)) - { - require $path; - - return; - } - } -}); +spl_autoload_register(array('System\\Loader', 'load')); // -------------------------------------------------------------- // Register the framework starting time with the Benchmarker. diff --git a/system/loader.php b/system/loader.php new file mode 100644 index 00000000..e0f69e42 --- /dev/null +++ b/system/loader.php @@ -0,0 +1,71 @@ +