Skip to content

Commit 23785c6

Browse files
committed
Fix wrong config namespace in subfolder
1 parent f04cf07 commit 23785c6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

system/Commands/Generators/ConfigGenerator.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
namespace CodeIgniter\Commands\Generators;
1313

1414
use CodeIgniter\CLI\BaseCommand;
15-
use CodeIgniter\CLI\CLI;
1615
use CodeIgniter\CLI\GeneratorTrait;
1716

1817
/**
19-
* Generates a skeleton Config file.
18+
* Generates a skeleton config file.
2019
*/
2120
class ConfigGenerator extends BaseCommand
2221
{
@@ -93,9 +92,13 @@ public function run(array $params)
9392
*/
9493
protected function prepare(string $class): string
9594
{
96-
$namespace = $this->getOption('namespace');
97-
$namespace = is_string($namespace) ? $namespace . '\\' . $this->directory : $this->directory;
95+
$namespace = $this->getOption('namespace') ?? APP_NAMESPACE;
9896

99-
return $this->parseTemplate($class, ['{namespace}'], [$namespace]);
97+
if ($namespace === APP_NAMESPACE)
98+
{
99+
$class = substr($class, strlen($namespace . '\\'));
100+
}
101+
102+
return $this->parseTemplate($class);
100103
}
101104
}

0 commit comments

Comments
 (0)