From 3ae09ec6527d17375b07b1d642c47f72a70c912f Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 15 May 2014 21:17:20 +0200 Subject: [PATCH] Added scanApplicationClasses(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- inc/loader/class_ClassLoader.php | 37 ++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php index dce3df9c..cc7bb815 100644 --- a/inc/loader/class_ClassLoader.php +++ b/inc/loader/class_ClassLoader.php @@ -98,6 +98,17 @@ class ClassLoader { */ private $total = 0; + /** + * Framework/application paths for classes, etc. + */ + private static $frameworkPaths = array( + 'exceptions', // Exceptions + 'interfaces', // Interfaces + 'main', // General main classes + 'middleware' // The middleware + ); + + /** * The protected constructor. Please use the factory method below, or use * getSelfInstance() for singleton @@ -163,24 +174,32 @@ class ClassLoader { * @return void */ public static function scanFrameworkClasses () { - // Lower framework classes - $lowerClasses = array( - 'exceptions', // Exceptions - 'interfaces', // Interfaces - 'main', // General main classes - 'middleware' // The middleware - ); - // Cache loader instance $loaderInstance = self::getSelfInstance(); // Load all classes - foreach ($lowerClasses as $className) { + foreach (self::$frameworkPaths as $className) { // Try to load the framework classes $loaderInstance->scanClassPath('inc/classes/' . $className . '/'); } // END - foreach } + /** + * Scans for application's classes, etc. + * + * @return void + */ + public static function scanApplicationClasses () { + // Get config instance + $cfg = FrameworkConfiguration::getSelfInstance(); + + // Load all classes for the application + foreach (self::$frameworkPaths as $class) { + // Try to load the application classes + ClassLoader::getSelfInstance()->scanClassPath(sprintf('%s/%s/%s', $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class)); + } // END - foreach + } + /** * Initializes our loader class * -- 2.39.5