| 1 | <?php |
||
| 9 | class FailedJobNotifier |
||
| 10 | { |
||
| 11 | public function register() |
||
| 12 | { |
||
| 13 | app(QueueManager::class)->failing(function (JobFailed $event) { |
||
| 14 | $notifiable = app(config('laravel-failed-job-monitor.notifiable')); |
||
| 15 | $notification = app(config('laravel-failed-job-monitor.notification'))->setEvent($event); |
||
| 16 | |||
| 17 | if (!$this->isValidNotificationClass($notification)) { |
||
| 18 | throw new InvalidNotificationException( |
||
| 19 | "Class {get_class($notification)} must extend " . Notification::class |
||
| 20 | ); |
||
| 21 | } |
||
| 22 | |||
| 23 | $notifiable->notify($notification); |
||
| 24 | }); |
||
| 25 | |||
| 26 | } |
||
| 27 | |||
| 28 | public function isValidNotificationClass($notification):bool |
||
| 32 | } |
||
| 33 |