diff --git a/src/Command/CreateCommand.php b/src/Command/CreateCommand.php index 27466ae..33b26ce 100644 --- a/src/Command/CreateCommand.php +++ b/src/Command/CreateCommand.php @@ -59,6 +59,14 @@ public function __invoke(): int return AbstractCommand::SUCCESS; } + public function createNamespace(string $path, string $name): string + { + $pluginPath = Str::replace(Plugin::PLUGIN_PATH . '/', '', $path); + list($orgName) = explode('/', $pluginPath); + + return 'Plugin\\' . Str::studly($orgName) . '\\' . Str::studly($name); + } + public function createMineJson(string $path, string $name, PluginTypeEnum $pluginType): void { $output = new \stdClass(); @@ -73,7 +81,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi ], ]; if ($pluginType === PluginTypeEnum::Backend || $pluginType === PluginTypeEnum::Mix) { - $namespace = 'Plugin\\' . Str::studly($name); + $namespace = $this->createNamespace($path, $name) ?? 'Plugin\\' . Str::studly($name); $this->createInstallScript($namespace, $path); $this->createUninstallScript($namespace, $path);