src/EventListener/EventRescheduledListener.php line 27

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 EventRescheduledListener
  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.         $this->eventEmailManager->sendReschedulingNotify($event);
  26.     }
  27.     public function sendReschedulingNotifyToInvitee(GenericEvent $event): void
  28.     {
  29.         /** @var EventInterface $event */
  30.         $event $event->getSubject();
  31.         Assert::isInstanceOf($eventEventInterface::class);
  32.         if (false === ($this->allowedSendingEmailNotificationToInviteePolicy)($event)) {
  33.             return;
  34.         }
  35.         $this->eventEmailManager->sendReschedulingNotifyToInvitee($event);
  36.     }
  37. }