This commit is contained in:
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Notification;
|
||||
|
||||
use App\Notification\Ntfy;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
class Notification
|
||||
{
|
||||
@ -13,6 +14,10 @@ class Notification
|
||||
*/
|
||||
private array $notifiers = array();
|
||||
|
||||
public function __construct(private NullLogger $logger = new NullLogger())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Load multiple configurations
|
||||
*
|
||||
@ -63,7 +68,11 @@ class Notification
|
||||
public function send(string $title, string $message): void
|
||||
{
|
||||
foreach ($this->getNotifiers() as $notifier) {
|
||||
$notifier->send($title, $message);
|
||||
try {
|
||||
$notifier->send($title, $message);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,5 +6,6 @@ namespace App\Notification;
|
||||
|
||||
interface NotificationInterface
|
||||
{
|
||||
static function factory(array $config): self;
|
||||
public function send(string $title, string $message): void;
|
||||
}
|
||||
|
Reference in New Issue
Block a user