src/Notification/EventSubscriber/SendCreatedNotificationSubscriber.php line 48
<?phpdeclare(strict_types=1);/*** Copyright (c) 2021 TECLA Consulting Group oü.* All rights reserved.** This unpublished material is proprietary to TECLA Consulting Group oü.* All rights reserved. The methods and* techniques described herein are considered trade secrets* and/or confidential. Reproduction or distribution, in whole* or in part, is forbidden except by express written permission* of TECLA Consulting Group oü.** @author Matúš Sýkorjak <matus@tecla.no>* @copyright 2021 TECLA Consulting Group oü*/namespace App\Notification\EventSubscriber;use App\Notification\Event\Notification\CreatedEvent;use App\Notification\Exception\EmptyRecipientEmailExceptionInterface;use App\Notification\Util\NotificationEmailSenderInterface;use JetBrains\PhpStorm\ArrayShape;use Psr\Log\LoggerInterface;use Symfony\Component\EventDispatcher\EventSubscriberInterface;final class SendCreatedNotificationSubscriber implements EventSubscriberInterface{private NotificationEmailSenderInterface $emailSender;private LoggerInterface $logger;public function __construct(NotificationEmailSenderInterface $emailSender, LoggerInterface $logger){$this->emailSender = $emailSender;$this->logger = $logger;}#[ArrayShape([CreatedEvent::class => 'string'])]public static function getSubscribedEvents(): array{return [CreatedEvent::class => 'onCreated',];}public function onCreated(CreatedEvent $event): void{try {$this->emailSender->send($event->getNotification());} catch (EmptyRecipientEmailExceptionInterface $e) {$this->logger->error('Recipient\'s e-mail address is empty.', ['exception' => $e,]);}}}