diff --git a/system/Config/Config.php b/system/Config/Config.php index ba80348a0b14..1abfd05d2359 100644 --- a/system/Config/Config.php +++ b/system/Config/Config.php @@ -122,13 +122,28 @@ private static function createClass(string $name) { return new $name(); } - + $locator = Services::locator(); $file = $locator->locateFile($name, 'Config'); - + if (empty($file)) { - return null; + // No file found - check if the class was namespaced + if (strpos($name, '\\') !== false) + { + // Class was namespaced and locateFile couldn't find it + return null; + } + + // Check all namespaces + $files = $locator->search('Config/' . $name); + if (empty($files)) + { + return null; + } + + // Get the first match (prioritizes user and framework) + $file = reset($files); } $name = $locator->getClassname($file);