src/Service/Panel/Api/SmsGateway/EventSubscriber/SendSmsSubscriber.php line 45

Open in your IDE?
  1. <?php
  2. namespace Harmonizely\Service\Panel\Api\SmsGateway\EventSubscriber;
  3. use Harmonizely\CalendarEvents;
  4. use Harmonizely\Model\Event;
  5. use Harmonizely\Service\Panel\Api\SmsGateway\Contract\ISendSmsForEventTemplate;
  6. use Harmonizely\Types\SmsTemplateType;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\EventDispatcher\GenericEvent;
  9. class SendSmsSubscriber implements EventSubscriberInterface
  10. {
  11.     /**
  12.      * @var ISendSmsForEventTemplate
  13.      */
  14.     private ISendSmsForEventTemplate $sendSmsForEventTemplate;
  15.     /**
  16.      * @param ISendSmsForEventTemplate $sendSmsForEventTemplate
  17.      */
  18.     public function __construct(ISendSmsForEventTemplate $sendSmsForEventTemplate)
  19.     {
  20.         $this->sendSmsForEventTemplate $sendSmsForEventTemplate;
  21.     }
  22.     /**
  23.      * @return string[]
  24.      */
  25.     public static function getSubscribedEvents(): array
  26.     {
  27.         return [
  28.             CalendarEvents::EVENT_POST_CREATE => 'create',
  29.             CalendarEvents::EVENT_POST_RESCHEDULE => 'reschedule',
  30.             CalendarEvents::EVENT_POST_CANCEL => 'cancel',
  31.         ];
  32.     }
  33.     /**
  34.      * @param GenericEvent $genericEvent
  35.      * @return void
  36.      */
  37.     public function create(GenericEvent $genericEvent): void
  38.     {
  39.         /** @var Event $event */
  40.         $event $genericEvent->getSubject();
  41.         $this->sendSmsForEventTemplate->perform($eventSmsTemplateType::TYPE_EVENT_SCHEDULED);
  42.     }
  43.     /**
  44.      * @param GenericEvent $genericEvent
  45.      * @return void
  46.      */
  47.     public function reschedule(GenericEvent $genericEvent): void
  48.     {
  49.         /** @var Event $event */
  50.         $event $genericEvent->getSubject();
  51.         $this->sendSmsForEventTemplate->perform($eventSmsTemplateType::TYPE_EVENT_RESCHEDULED);
  52.     }
  53.     /**
  54.      * @param GenericEvent $genericEvent
  55.      * @return void
  56.      */
  57.     public function cancel(GenericEvent $genericEvent): void
  58.     {
  59.         /** @var Event $event */
  60.         $event $genericEvent->getSubject();
  61.         $this->sendSmsForEventTemplate->perform($eventSmsTemplateType::TYPE_EVENT_CANCELED);
  62.     }
  63. }