Skip to content

Commit

Permalink
allow bindings and singletons properties
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 10, 2017
1 parent f16d2c0 commit 81e29b1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,18 @@ public function register($provider, $options = [], $force = false)
$provider->register();
}

if (property_exists($provider, 'bind')) {
foreach ($provider->bind as $abstract => $concrete) {
$this->bind($abstract, $concrete);
// If there are bindings / singletons set as properties on the provider we
// will spin through them and register them with the application, which
// serves as a convenience layer while registering a lot of bindings.
if (property_exists($provider, 'bindings')) {
foreach ($provider->bindings as $key => $value) {
$this->bind($key, $value);
}
}

if (property_exists($provider, 'singletons')) {
foreach ($provider->singletons as $abstract => $concrete) {
$this->singleton($abstract, $concrete);
foreach ($provider->singletons as $key => $value) {
$this->singleton($key, $value);
}
}

Expand Down

2 comments on commit 81e29b1

@gocanto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is good.

@dallincoons
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you also want to update the bind property in FoundationApplicationTest?

Please sign in to comment.