diff --git a/src/Commands/Traits/StubTrait.php b/src/Commands/Traits/StubTrait.php index 54fe8c3..9772079 100644 --- a/src/Commands/Traits/StubTrait.php +++ b/src/Commands/Traits/StubTrait.php @@ -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'); } /** diff --git a/src/Plugin.php b/src/Plugin.php index d19bdd5..d6c2c4a 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -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) {