Skip to content

Commit

Permalink
Replace Provider with Subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
tjardoo committed Jun 10, 2024
1 parent 2af5ed9 commit 3ae9ce4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/MailViewerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Label84\MailViewer;

use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Label84\MailViewer\Providers\EventServiceProvider;
use Label84\MailViewer\Subscribers\MessageSentSubscriber;

class MailViewerServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -38,7 +39,7 @@ public function register(): void
'mailviewer'
);

$this->app->register(EventServiceProvider::class);
Event::subscribe(MessageSentSubscriber::class);
}

protected function registerRoutes(): void
Expand Down
15 changes: 15 additions & 0 deletions src/Subscribers/MessageSentSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Label84\MailViewer\Subscribers;

use Illuminate\Events\Dispatcher;
use Illuminate\Mail\Events\MessageSent;
use Label84\MailViewer\Listeners\CreateMailViewerItem;

class MessageSentSubscriber
{
public function subscribe(Dispatcher $events): void
{
$events->listen(MessageSent::class, [CreateMailViewerItem::class, 'handle']);
}
}

0 comments on commit 3ae9ce4

Please sign in to comment.