From: Roland Haeder Date: Sat, 4 Mar 2017 21:26:54 +0000 (+0100) Subject: Proper way of searching for paths X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2dafded363adcb6fd8dd2b26aa3d894d3b4ff082;p=core.git Proper way of searching for paths Signed-off-by: Roland Häder --- diff --git a/framework/loader/class_ClassLoader.php b/framework/loader/class_ClassLoader.php index f4a69ab6..5ef930ce 100644 --- a/framework/loader/class_ClassLoader.php +++ b/framework/loader/class_ClassLoader.php @@ -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