32 lines
686 B
PHP
32 lines
686 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Notification;
|
||
|
|
||
|
class Notification
|
||
|
{
|
||
|
/**
|
||
|
* @type NotificationInterface[] $notifiers
|
||
|
*/
|
||
|
public array $notifiers = array();
|
||
|
public function loadMany(array $config): void
|
||
|
{
|
||
|
foreach ($config as $key => $conf) {
|
||
|
$this->loadSingle($key, $conf);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function loadSingle(string $key, array $config): void
|
||
|
{
|
||
|
$class = "\App\Notification\\" . $key;
|
||
|
|
||
|
$this->notifiers[$key] = new $class($config);
|
||
|
}
|
||
|
|
||
|
public function send(string $title, string $message): void
|
||
|
{
|
||
|
foreach ($this->notifiers as $notifier) {
|
||
|
$notifier->send($title, $message);
|
||
|
}
|
||
|
}
|
||
|
}
|