]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/Handlers/PageCreationNotificationHandler.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Activity / Notifications / Handlers / PageCreationNotificationHandler.php
1 <?php
2
3 namespace BookStack\Activity\Notifications\Handlers;
4
5 use BookStack\Activity\Models\Activity;
6 use BookStack\Activity\Models\Loggable;
7 use BookStack\Activity\Notifications\Messages\PageCreationNotification;
8 use BookStack\Activity\Tools\EntityWatchers;
9 use BookStack\Activity\WatchLevels;
10 use BookStack\Entities\Models\Page;
11 use BookStack\Users\Models\User;
12
13 class PageCreationNotificationHandler extends BaseNotificationHandler
14 {
15     public function handle(Activity $activity, Loggable|string $detail, User $user): void
16     {
17         if (!($detail instanceof Page)) {
18             throw new \InvalidArgumentException("Detail for page create notifications must be a page");
19         }
20
21         $watchers = new EntityWatchers($detail, WatchLevels::NEW);
22         $this->sendNotificationToUserIds(PageCreationNotification::class, $watchers->getWatcherUserIds(), $user, $detail, $detail);
23     }
24 }