Skip to content

Commit

Permalink
规范应用 namespace (#130)
Browse files Browse the repository at this point in the history
Co-authored-by: frank <noikiy@qq.com>
  • Loading branch information
gladtoeatu and frank authored Nov 14, 2024
1 parent d23f28d commit 12b7d21
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ 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();
Expand All @@ -74,7 +81,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi
],
];
if ($pluginType === PluginTypeEnum::Backend || $pluginType === PluginTypeEnum::Mix) {
$namespace = 'Plugin\\' . ucwords(str_replace('/', '\\', Str::studly($name)));
$namespace = $this->createNamespace($path, $name) ?? 'Plugin\\' . ucwords(str_replace('/', '\\', Str::studly($name)));

$this->createInstallScript($namespace, $path);
$this->createUninstallScript($namespace, $path);
Expand Down

0 comments on commit 12b7d21

Please sign in to comment.