29.07.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Service Container 129<br />

.<br />

35 }<br />

36 }<br />

Container Events<br />

The service container fires an event each time it resolves an object. You may listen to this event<br />

using the resolving method:<br />

.<br />

1 $this->app->resolving(function ($object, $app) {<br />

2 // Called when container resolves object of any type...<br />

3 });<br />

4<br />

5 $this->app->resolving(FooBar::class, function (FooBar $fooBar, $app) {<br />

6 // Called when container resolves objects of type "FooBar"...<br />

7 });<br />

As you can see, the object being resolved will be passed to the callback, allowing you to set any<br />

additional properties on the object before it is given to its consumer.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!