diff --git a/cake/libs/app.php b/cake/libs/app.php index f18bb071970..66df9c93b4a 100644 --- a/cake/libs/app.php +++ b/cake/libs/app.php @@ -201,6 +201,12 @@ class App { */ private static $__objects = array(); +/** + * Holds the location of each class + * + */ + private static $__classMap = array(); + /** * Used to read information stored path * @@ -430,6 +436,17 @@ public static function setObjects($type, $values) { self::$__objects[$type] = $values; } + public static function uses($className, $location) { + self::$__classMap[$className] = $location; + } + + public static function load($className) { + if (isset(self::$__classMap[$className])) { + return App::import(self::$__classMap[$className], $className, false); + } + return false; + } + /** * Finds classes based on $name or specific file(s) to search. Calling App::import() will * not construct any classes contained in the files. It will only find and require() the file. @@ -887,3 +904,5 @@ public static function shutdown() { } } } + +spl_autoload_register(array('App', 'load')); \ No newline at end of file diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index cb14d18ba82..1a3738e893c 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -24,10 +24,12 @@ /** * List of helpers to include */ -App::import('Core', 'Router', false); -App::import('Core', 'CakeRequest', false); -App::import('Core', 'CakeResponse', false); -App::import('Controller', 'Controller', false); +App::uses('Router', 'Core'); +App::uses('CakeRequest', 'Core'); +App::uses('CakeResponse', 'Core'); +App::uses('Controller', 'Controller'); +App::uses('View', 'View'); +App::uses('Debugger', 'Core'); /** * Dispatcher converts Requests into controller actions. It uses the dispatched Request @@ -270,9 +272,6 @@ public function cached($url) { } if (file_exists($filename)) { - if (!class_exists('View')) { - App::import('View', 'View', false); - } $controller = null; $view = new View($controller); return $view->renderCache($filename, microtime(true));