Skip to content

Commit

Permalink
Improve the Notifications Service
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyCyborg committed Jul 25, 2019
1 parent 695deea commit 379175e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
10 changes: 3 additions & 7 deletions src/Notifications/ChannelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
13 changes: 5 additions & 8 deletions src/Notifications/NotificationSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/**
Expand Down
12 changes: 9 additions & 3 deletions src/Notifications/NotificationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Nova\Bus\DispatcherInterface as BusDispatcher;
use Nova\Notifications\ChannelManager;
use Nova\Notifications\NotificationSender;
use Nova\Support\ServiceProvider;


Expand All @@ -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']);
});
}

Expand All @@ -39,6 +45,6 @@ public function register()
*/
public function provides()
{
return array('notifications');
return array('notifications', 'notifications.sender');
}
}

0 comments on commit 379175e

Please sign in to comment.