I have the following definition:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\SomeClass;
class SomeProvider extends ServiceProvider
{
protected $defer = true;
public function register()
{
$this->app->bind(SomeClass::class, function ($app)
{
return new SomeClass();
});
}
public function provides()
{
die("This never gets called");
return [SomeClass::class];
}
}
And it returns an instance of SomeClass
as expected, except that according to the documentation, if $defer
is true then the provides()
method should be called. No matter what I set $defer
to, and no matter if I actually ask for an instance of SomeClass
or not, provides()
is never called.
The way I'm asking for an instance of the class is as follows:
App::make('SomeClass');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire