25 lines
		
	
	
		
			896 B
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			896 B
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace BookStack\Activity\Notifications\Handlers;
 | |
| 
 | |
| use BookStack\Activity\Models\Activity;
 | |
| use BookStack\Activity\Models\Loggable;
 | |
| use BookStack\Activity\Notifications\Messages\PageCreationNotification;
 | |
| use BookStack\Activity\Tools\EntityWatchers;
 | |
| use BookStack\Activity\WatchLevels;
 | |
| use BookStack\Entities\Models\Page;
 | |
| use BookStack\Users\Models\User;
 | |
| 
 | |
| class PageCreationNotificationHandler extends BaseNotificationHandler
 | |
| {
 | |
|     public function handle(Activity $activity, Loggable|string $detail, User $user): void
 | |
|     {
 | |
|         if (!($detail instanceof Page)) {
 | |
|             throw new \InvalidArgumentException("Detail for page create notifications must be a page");
 | |
|         }
 | |
| 
 | |
|         $watchers = new EntityWatchers($detail, WatchLevels::NEW);
 | |
|         $this->sendNotificationToUserIds(PageCreationNotification::class, $watchers->getWatcherUserIds(), $user, $detail, $detail);
 | |
|     }
 | |
| }
 |