File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 77use Hyperf \Collection \Arr ;
88use Hyperf \Config \ProviderConfig as HyperfProviderConfig ;
99use Hyperf \Support \Composer ;
10+ use Hypervel \Support \ServiceProvider ;
1011use Throwable ;
1112
1213/**
@@ -51,6 +52,27 @@ public static function load(): array
5152 );
5253 }
5354
55+ protected static function loadProviders (array $ providers ): array
56+ {
57+ $ providerConfigs = [];
58+ foreach ($ providers as $ provider ) {
59+ if (! is_string ($ provider ) || ! class_exists ($ provider )) {
60+ continue ;
61+ }
62+ if (is_subclass_of ($ provider , ServiceProvider::class)
63+ && $ providerConfig = $ provider ::getProviderConfig ()
64+ ) {
65+ $ providerConfigs [] = $ providerConfig ;
66+ continue ;
67+ }
68+ if (method_exists ($ provider , '__invoke ' )) {
69+ $ providerConfigs [] = (new $ provider ())();
70+ }
71+ }
72+
73+ return static ::merge (...$ providerConfigs );
74+ }
75+
5476 protected static function packagesToIgnore (): array
5577 {
5678 $ packages = Composer::getMergedExtra ('hypervel ' )['dont-discover ' ] ?? [];
Original file line number Diff line number Diff line change @@ -322,4 +322,12 @@ public static function defaultProviders(): DefaultProviders
322322 {
323323 return new DefaultProviders ();
324324 }
325+
326+ /**
327+ * Get the provider config for Hyperf framework.
328+ */
329+ public static function getProviderConfig (): array
330+ {
331+ return [];
332+ }
325333}
You can’t perform that action at this time.
0 commit comments