From 2dafded363adcb6fd8dd2b26aa3d894d3b4ff082 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 4 Mar 2017 22:26:54 +0100 Subject: [PATCH] Proper way of searching for paths MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- framework/loader/class_ClassLoader.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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 -- 2.39.5