From 27acc49025010eedbe7e92509245e3519565e283 Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 14 Nov 2024 15:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=BA=94=E7=94=A8=20namespac?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Command/CreateCommand.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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);