-
-
Notifications
You must be signed in to change notification settings - Fork 829
/
ReadAllNotificationsHandler.php
53 lines (43 loc) · 1.21 KB
/
ReadAllNotificationsHandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Notification\Command;
use Flarum\Notification\Event\ReadAll;
use Flarum\Notification\NotificationRepository;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\Carbon;
class ReadAllNotificationsHandler
{
/**
* @var NotificationRepository
*/
protected $notifications;
/**
* @var Dispatcher
*/
protected $events;
/**
* @param NotificationRepository $notifications
* @param Dispatcher $events
*/
public function __construct(NotificationRepository $notifications, Dispatcher $events)
{
$this->notifications = $notifications;
$this->events = $events;
}
/**
* @param ReadAllNotifications $command
* @throws \Flarum\User\Exception\PermissionDeniedException
*/
public function handle(ReadAllNotifications $command)
{
$actor = $command->actor;
$actor->assertRegistered();
$this->notifications->markAllAsRead($actor);
$this->events->dispatch(new ReadAll($actor, Carbon::now()));
}
}