Skip to content

Commit 8a65911

Browse files
committed
Fixed bug with singletons and providers.
Signed-off-by: Joshua Parker <[email protected]>
1 parent ab92266 commit 8a65911

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Configuration/ApplicationBuilder.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Codefy\Framework\Application;
88
use Codefy\Framework\Bootstrap\RegisterProviders;
9+
use Qubus\Exception\Data\TypeException;
910

1011
final class ApplicationBuilder
1112
{
@@ -38,11 +39,16 @@ public function withKernels(): self
3839
*
3940
* @param array $providers
4041
* @return $this
42+
* @throws TypeException
4143
*/
4244
public function withProviders(array $providers = []): self
4345
{
4446
RegisterProviders::merge($providers);
4547

48+
foreach ($providers as $provider) {
49+
$this->app->registerServiceProvider($provider);
50+
}
51+
4652
return $this;
4753
}
4854

@@ -59,11 +65,9 @@ public function withSingletons(array $singletons = []): self
5965
return $this;
6066
}
6167

62-
$this->registered(function ($app) use ($singletons) {
63-
foreach ($singletons as $key => $callable) {
64-
$app->singleton($key, $callable);
65-
}
66-
});
68+
foreach ($singletons as $key => $callable) {
69+
$this->app->singleton($key, $callable);
70+
};
6771

6872
return $this;
6973
}

0 commit comments

Comments
 (0)