One BusServiceProvider is enough

This commit is contained in:
Franz Liedke 2018-08-03 00:38:44 +02:00
parent 2d4802d637
commit 98aaa6a130
2 changed files with 13 additions and 5 deletions

View File

@ -12,17 +12,27 @@
namespace Flarum\Bus;
use Flarum\Foundation\AbstractServiceProvider;
use Illuminate\Contracts\Bus\Dispatcher as BusContract;
use Illuminate\Bus\Dispatcher as BaseDispatcher;
use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
use Illuminate\Contracts\Bus\QueueingDispatcher as QueueingDispatcherContract;
use Illuminate\Contracts\Queue\Factory as QueueFactoryContract;
class BusServiceProvider extends AbstractServiceProvider
{
public function register()
{
$this->app->bind(BusContract::class, function ($app) {
$this->app->bind(BaseDispatcher::class, function ($app) {
return new Dispatcher($app, function ($connection = null) use ($app) {
return $app[QueueFactoryContract::class]->connection($connection);
});
});
$this->app->alias(
BaseDispatcher::class, DispatcherContract::class
);
$this->app->alias(
BaseDispatcher::class, QueueingDispatcherContract::class
);
}
}

View File

@ -13,7 +13,7 @@ namespace Flarum\Foundation;
use Flarum\Admin\AdminServiceProvider;
use Flarum\Api\ApiServiceProvider;
use Flarum\Bus\BusServiceProvider as BusProvider;
use Flarum\Bus\BusServiceProvider;
use Flarum\Database\DatabaseServiceProvider;
use Flarum\Database\MigrationServiceProvider;
use Flarum\Discussion\DiscussionServiceProvider;
@ -125,8 +125,6 @@ class InstalledSite implements SiteInterface
$laravel->register(ViewServiceProvider::class);
$laravel->register(ValidationServiceProvider::class);
$laravel->register(BusProvider::class);
$settings = $laravel->make(SettingsRepositoryInterface::class);
$config->set('mail.driver', $settings->get('mail_driver'));