From 98aaa6a130479571d2ac2112c67631d2a76875b7 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 3 Aug 2018 00:38:44 +0200 Subject: [PATCH] One BusServiceProvider is enough --- framework/core/src/Bus/BusServiceProvider.php | 14 ++++++++++++-- framework/core/src/Foundation/InstalledSite.php | 4 +--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/framework/core/src/Bus/BusServiceProvider.php b/framework/core/src/Bus/BusServiceProvider.php index c07b9b812..938da0c55 100644 --- a/framework/core/src/Bus/BusServiceProvider.php +++ b/framework/core/src/Bus/BusServiceProvider.php @@ -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 + ); } } diff --git a/framework/core/src/Foundation/InstalledSite.php b/framework/core/src/Foundation/InstalledSite.php index dd6740a30..f30d29625 100644 --- a/framework/core/src/Foundation/InstalledSite.php +++ b/framework/core/src/Foundation/InstalledSite.php @@ -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'));