locateFile($name, 'Config'); if (empty($file)) { // 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); if (empty($name)) { return null; } return new $name(); } //-------------------------------------------------------------------- }