Skip to content

Commit

Permalink
规范应用 namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
frank committed Nov 14, 2024
1 parent 960ecf7 commit 27acc49
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 27acc49

Please sign in to comment.