Skip to content

Commit

Permalink
chore: service provider class
Browse files Browse the repository at this point in the history
  • Loading branch information
jevantang committed Mar 27, 2024
1 parent 0fca827 commit 582eb5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/Commands/Traits/StubTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,21 @@ public function getPluginJsonReplaceContent($provider, $pluginFskey): string

public function getPluginJsonSearchContent($pluginFskey): string
{
$class = sprintf('Plugins\\%s\\Providers\\%sServiceProvider', $pluginFskey, $pluginFskey);
$class = str_replace('\\', '\\\\', $class);
$pluginServiceProvider = sprintf('Plugins\\%s\\Providers\\PluginServiceProvider', $pluginFskey);
if (class_exists($pluginServiceProvider)) {
$class = str_replace('\\', '\\\\', $pluginServiceProvider);

return $class;
return $class;
}

$serviceProvider = sprintf('%s\\Providers\\%sServiceProvider', $pluginFskey, $pluginFskey);
if (class_exists($serviceProvider)) {
$class = str_replace('\\', '\\\\', $serviceProvider);

return $class;
}

throw new \RuntimeException('Service provider for the plugin not found');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function isAvailablePlugin(?string $pluginFskey = null)
$plugin->manualAddNamespace();

$serviceProvider = sprintf('%s\\Providers\\%sServiceProvider', $plugin->getClassNamespace(), $pluginFskey);
$pluginServiceProvider = sprintf('%s\\Providers\\PluginServiceProvider', $plugin->getClassNamespace(), $pluginFskey);
$pluginServiceProvider = sprintf('%s\\Providers\\PluginServiceProvider', $plugin->getClassNamespace());

return class_exists($serviceProvider) || class_exists($pluginServiceProvider);
} catch (\Throwable $e) {
Expand Down

0 comments on commit 582eb5b

Please sign in to comment.