]> git.mxchange.org Git - core.git/blobdiff - inc/loader/class_ClassLoader.php
Continued:
[core.git] / inc / loader / class_ClassLoader.php
index ed5b7825fcba6f8364f4715536e392394034ce02..eee9fce15e85d458920073785c1e5ce842a64216 100644 (file)
@@ -7,6 +7,7 @@ use CoreFramework\Configuration\FrameworkConfiguration;
 use CoreFramework\Object\BaseFrameworkSystem;
 
 // Import SPL stuff
+use \InvalidArgumentException;
 use \RecursiveDirectoryIterator;
 use \RecursiveIteratorIterator;
 
@@ -35,8 +36,8 @@ use \RecursiveIteratorIterator;
  * ----------------------------------
  * 1.5
  *  - Namespace scheme Project\Package[\SubPackage...] is fully supported and
- *    throws an E_USER_WARNING if not present. The last part will be always the
- *    class' name.
+ *    throws an InvalidArgumentException if not present. The last part will be
+ *    always the class' name.
  * 1.4
  *  - Some comments improved, other minor improvements
  * 1.3
@@ -189,11 +190,17 @@ class ClassLoader {
         * @return      void
         */
        public static function scanFrameworkClasses () {
+               // Trace message
+               /* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+
                // Cache loader instance
                $loaderInstance = self::getSelfInstance();
 
                // Load all classes
                foreach (self::$frameworkPaths as $pathName) {
+                       // Debug message
+                       /* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
+
                        // Try to load the framework classes
                        $loaderInstance->scanClassPath('inc/main/' . $pathName . '/');
                } // END - foreach
@@ -205,18 +212,24 @@ class ClassLoader {
         * @return      void
         */
        public static function scanApplicationClasses () {
+               // Trace message
+               /* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+
                // Get config instance
                $cfg = FrameworkConfiguration::getSelfInstance();
 
                // Load all classes for the application
                foreach (self::$frameworkPaths as $class) {
                        // Create path name
-                       $path = sprintf('%s/%s/%s', $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class);
+                       $pathName = sprintf('%s/%s/%s', $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class);
+
+                       // Debug message
+                       /* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
 
                        // Is the path readable?
-                       if (is_dir($path)) {
+                       if (is_dir($pathName)) {
                                // Try to load the application classes
-                               ClassLoader::getSelfInstance()->scanClassPath($path);
+                               ClassLoader::getSelfInstance()->scanClassPath($pathName);
                        } // END - if
                } // END - foreach
        }
@@ -422,7 +435,7 @@ class ClassLoader {
                // At least 3 parts should be there
                if (count($classNameParts) < 3) {
                        // Namespace scheme is: Project\Package[\SubPackage...]
-                       trigger_error(sprintf('Class name "%s" is not conform to naming-convention: Project\Package[\SubPackage...]\SomeFooBar', $className), E_USER_WARNING);
+                       throw new InvalidArgumentException(sprintf('Class name "%s" is not conform to naming-convention: Project\Package[\SubPackage...]\SomeFooBar', $className));
                } // END - if
 
                // Get last element