diff --git a/src/Notifications/ChannelManager.php b/src/Notifications/ChannelManager.php index 23397083..b1eb87de 100644 --- a/src/Notifications/ChannelManager.php +++ b/src/Notifications/ChannelManager.php @@ -2,8 +2,6 @@ namespace Nova\Notifications; -use Nova\Bus\DispatcherInterface as BusDispatcher; -use Nova\Events\Dispatcher as EventDispatcher; use Nova\Foundation\Application; use Nova\Support\Manager; @@ -37,16 +35,14 @@ class ChannelManager extends Manager implements DispatcherInterface * Create a new manager instance. * * @param \Nova\Foundation\Application $app - * @param \Nova\Bus\Dispatcher $bus - * @param \Nova\Events\Dispatcher $events + * @param \Nova\Notifications\NotificationSender $sender * @return void */ - public function __construct(Application $app, BusDispatcher $bus, EventDispatcher $events) + public function __construct(Application $app, NotificationSender $sender) { $this->app = $app; - // - $this->sender = new NotificationSender($this, $bus, $events); + $this->sender = $sender; } /** diff --git a/src/Notifications/NotificationSender.php b/src/Notifications/NotificationSender.php index 2d388fd6..48a37aac 100644 --- a/src/Notifications/NotificationSender.php +++ b/src/Notifications/NotificationSender.php @@ -5,13 +5,11 @@ use Nova\Bus\Dispatcher as BusDispatcher; use Nova\Database\ORM\Collection as ModelCollection; use Nova\Events\Dispatcher as EventDispatcher; -use Nova\Foundation\Application; use Nova\Queue\ShouldQueueInterface; use Nova\Support\Collection; use Nova\Notifications\Events\NotificationSending; use Nova\Notifications\Events\NotificationSent; -use Nova\Notifications\DispatcherInterface; use Nova\Notifications\SendQueuedNotifications; use Ramsey\Uuid\Uuid; @@ -46,16 +44,15 @@ class NotificationSender /** * Create a new notification sender instance. * - * @param \Nova\Notifications\ChannelManager $manager - * @param \Nova\Bus\Dispatcher $bus * @param \Nova\Events\Dispatcher $events + * @param \Nova\Bus\Dispatcher $bus * @return void */ - public function __construct(ChannelManager $manager, BusDispatcher $bus, EventDispatcher $events) + public function __construct(EventDispatcher $events, BusDispatcher $bus) { - $this->manager = $manager; - $this->bus = $bus; - $this->events = $events; + $this->events = $events; + + $this->bus = $bus; } /** diff --git a/src/Notifications/NotificationServiceProvider.php b/src/Notifications/NotificationServiceProvider.php index 7422577b..12c930f0 100644 --- a/src/Notifications/NotificationServiceProvider.php +++ b/src/Notifications/NotificationServiceProvider.php @@ -4,6 +4,7 @@ use Nova\Bus\DispatcherInterface as BusDispatcher; use Nova\Notifications\ChannelManager; +use Nova\Notifications\NotificationSender; use Nova\Support\ServiceProvider; @@ -24,11 +25,16 @@ class NotificationServiceProvider extends ServiceProvider */ public function register() { - $this->app->singleton('notifications', function ($app) + $this->app->singleton('notifications.sender', function ($app) { $bus = $app->make(BusDispatcher::class); - return new ChannelManager($app, $bus, $app['events']); + return new NotificationSender($app['events'], $bus); + }); + + $this->app->singleton('notifications', function ($app) + { + return new ChannelManager($app, $app['notifications.sender']); }); } @@ -39,6 +45,6 @@ public function register() */ public function provides() { - return array('notifications'); + return array('notifications', 'notifications.sender'); } }