Skip to content

Commit 94ac8e4

Browse files
authored
Merge pull request #215 from hypervel/hotfix/fix-config-provider-load
fix: fix registration of provider config in service providers
2 parents d23cf37 + e203b18 commit 94ac8e4

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/config/src/ProviderConfig.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Hyperf\Collection\Arr;
88
use Hyperf\Config\ProviderConfig as HyperfProviderConfig;
99
use Hyperf\Support\Composer;
10+
use Hypervel\Support\ServiceProvider;
1011
use 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'] ?? [];

src/support/src/ServiceProvider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)