Waavi/translation

Not supported with redis-sentinel caching

Opened this issue · 2 comments

Hey guys,

Trying to use https://github.com/monospice/laravel-redis-sentinel-drivers as my cache driver, and it won't let me load the driver at all if I have the Waavi/transaction service provider in my app.php config.

However, if I use the default laravel provider Illuminate\Translation\TranslationServiceProvider, it works fine and loads as expected. The developers over there suggested moving some of the logic into the boot() method so the cache driver can load properly monospice/laravel-redis-sentinel-drivers#17

Would you guys be able to help out with that and getting this different cache store supported?

Looks like the problem occurs when registering the package's cache flushing Artisan command. The package's service provider ultimately resolves Laravel's cache service from the container during the provider registration phase before other providers finish initializing in the boot phase.

It seems like we want to bind the command so it resolves at run time:

if ($this->app->runningInConsole()) {
    $this->app->bind('command.translator:flush', function ($app) {
        return new CacheFlushCommand($app['translation.cache.repository'], $app['config']->get('translator.cache.enabled'));
    }

    $this->commands('command.translator:flush');
}

Alternatively, initialize the command in the provider's boot() method so applications can order dependencies as needed. We may want to follow the same pattern to register the file loader.

Just in case there was any doubt, disabling the caching for waavi/translation via TRANSLATION_CACHE_ENABLED=false and everything works great.