Skip to content

Commit

Permalink
prevent providers duplicate register windwalker-io/core#1067
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Nov 6, 2023
1 parent 667f123 commit d83f23d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/di/src/Concern/ConfigRegisterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ protected function registerProviders(array $config, ?array &$providers = null):
$providers ??= [];

foreach ($config as $provider) {
$providers[] = $provider = $this->resolve($provider);
$provider = $this->resolve($provider);

if (array_key_exists($provider::class, $providers)) {
continue;
}

$providers[$provider::class] = $provider;

if ($provider instanceof ServiceProviderInterface) {
$this->registerServiceProvider($provider);
Expand Down

0 comments on commit d83f23d

Please sign in to comment.