src/EventListener/NewEventScheduledListener.php line 39

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Harmonizely\EventListener;
  4. use Harmonizely\EmailManager\EventEmailManagerInterface;
  5. use Harmonizely\Mailer\AllowedSendingEmailNotificationToInviteePolicy;
  6. use Harmonizely\Model\EventInterface;
  7. use Symfony\Component\EventDispatcher\GenericEvent;
  8. use Webmozart\Assert\Assert;
  9. final class NewEventScheduledListener
  10. {
  11.     private $eventEmailManager;
  12.     private AllowedSendingEmailNotificationToInviteePolicy $allowedSendingEmailNotificationToInviteePolicy;
  13.     public function __construct(
  14.         EventEmailManagerInterface $eventEmailManager,
  15.         AllowedSendingEmailNotificationToInviteePolicy $allowedSendingEmailNotificationToInviteePolicy
  16.     ) {
  17.         $this->eventEmailManager $eventEmailManager;
  18.         $this->allowedSendingEmailNotificationToInviteePolicy $allowedSendingEmailNotificationToInviteePolicy;
  19.     }
  20.     public function sendEmail(GenericEvent $event): void
  21.     {
  22.         /** @var EventInterface $event */
  23.         $event $event->getSubject();
  24.         Assert::isInstanceOf($eventEventInterface::class);
  25.         if (false === ($this->allowedSendingEmailNotificationToInviteePolicy)($event)) {
  26.             return;
  27.         }
  28.         $this->eventEmailManager->sendNewEventInviteeConfirmation($event);
  29.     }
  30.     public function sendNewEventEmailConfirmation(GenericEvent $event): void
  31.     {
  32.         /** @var EventInterface $event */
  33.         $event $event->getSubject();
  34.         Assert::isInstanceOf($eventEventInterface::class);
  35.         $this->eventEmailManager->sendNewEventEmailConfirmation($event);
  36.     }
  37. }