Skip to content

Commit cd97aba

Browse files
authored
Merge pull request #2079 from MGatner/config-namespaces
Update config() to check all namespaces
2 parents df4a21e + d8ba3e2 commit cd97aba

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

system/Config/Config.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,28 @@ private static function createClass(string $name)
122122
{
123123
return new $name();
124124
}
125-
125+
126126
$locator = Services::locator();
127127
$file = $locator->locateFile($name, 'Config');
128-
128+
129129
if (empty($file))
130130
{
131-
return null;
131+
// No file found - check if the class was namespaced
132+
if (strpos($name, '\\') !== false)
133+
{
134+
// Class was namespaced and locateFile couldn't find it
135+
return null;
136+
}
137+
138+
// Check all namespaces
139+
$files = $locator->search('Config/' . $name);
140+
if (empty($files))
141+
{
142+
return null;
143+
}
144+
145+
// Get the first match (prioritizes user and framework)
146+
$file = reset($files);
132147
}
133148

134149
$name = $locator->getClassname($file);

0 commit comments

Comments
 (0)