]> git.mxchange.org Git - core.git/commitdiff
Proper way of searching for paths
authorRoland Haeder <roland@mxchange.org>
Sat, 4 Mar 2017 21:26:54 +0000 (22:26 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 4 Mar 2017 21:26:54 +0000 (22:26 +0100)
Signed-off-by: Roland Häder <roland@mxchange.org>
framework/loader/class_ClassLoader.php

index f4a69ab6e6297889384d583b9811a43886dc2d40..5ef930ce25d6102f8baba52b90df27e6e76ca229 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Loader;
 
 // Import framework stuff
 use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\EntryPoint\ApplicationEntryPoint;
 use CoreFramework\Object\BaseFrameworkSystem;
 
 // Import SPL stuff
@@ -201,13 +202,35 @@ class ClassLoader {
                // Cache loader instance
                $loaderInstance = self::getSelfInstance();
 
+               // Get config instance
+               $cfg = FrameworkConfiguration::getSelfInstance();
+
                // Load all classes
                foreach (self::$frameworkPaths as $shortPath) {
                        // Debug message
                        //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
 
+                       // Generate full path from it
+                       $pathName = realpath(sprintf(
+                               '%s/framework/main/%s/',
+                               $cfg->getConfigEntry('base_path'),
+                               $shortPath
+                       ));
+
+                       // Debug message
+                       //* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
+
+                       // Is it not FALSE and accessible?
+                       if (is_bool($pathName)) {
+                               // Skip this
+                               continue;
+                       } elseif (!is_readable($pathName)) {
+                               // @TODO Throw exception instead of break
+                               break;
+                       }
+
                        // Try to load the framework classes
-                       $loaderInstance->scanClassPath(sprintf('framework/main/%s/', $shortPath));
+                       $loaderInstance->scanClassPath($pathName);
                } // END - foreach
 
                // Trace message