mercredi 30 septembre 2015

Laravel core class override in Service Provider not working in event listeners and Artisan Tinker

I created a service provider that overrides Laravel's Cache:

protected $defer = true;

public function register()
{
    $this->app->singleton('cache', function ($app) {
        return new CustomCacheManager($app);
    });
}

public function provides()
{
    return ['cache'];
}

If I run a call that constructs the cache like Cache:: or app('cache') in a request that outputs to the browser, all works fine and my own implementation of CustomCacheManager is working.

However in event listeners or even in artisan tinker my override isn't working and Laravel's own core class is being used.

Am I doing something wrong here? How can I make the override persistent across the whole application?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1KSCCt9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire