* @package oat\tao\model\extension */ abstract class AbstractNotificationService extends ConfigurableService { public const OPTION_NOTIFIERS = 'notifiers'; /** * @param Notification $notification */ public function sendNotifications(Notification $notification): void { if (!$this->hasOption(self::OPTION_NOTIFIERS) || !count($this->getOption(self::OPTION_NOTIFIERS))) { return; } $notifiers = $this->getOption(self::OPTION_NOTIFIERS); $this->notify($notification, $notifiers); } /** * @param Notification $notification * @param array $notifiers */ private function notify(Notification $notification, array $notifiers): void { foreach ($notifiers as $notifierConfig) { /**@var $notifier NotifierInterface */ $notifier = new $notifierConfig['class'](...$notifierConfig['params']); $notifier->notify($notification->getMessage(), $notification->getDescription()); } } }