src/App/EventSubscriber/App/NotificationEventSubscriber.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber\App;
  3. use App\Event\NotificationCanceledEvent;
  4. use App\Service\ConversionEventService;
  5. use App\Service\NotificationService;
  6. use Exception;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class NotificationEventSubscriber implements EventSubscriberInterface
  9. {
  10. /** @var NotificationService */
  11. private $notificationService;
  12. /** @var ConversionEventService */
  13. private $conversionEventService;
  14. public function __construct(NotificationService $notificationService, ConversionEventService $conversionEventService)
  15. {
  16. $this->notificationService = $notificationService;
  17. $this->conversionEventService = $conversionEventService;
  18. }
  19. public static function getSubscribedEvents()
  20. {
  21. return [
  22. NotificationCanceledEvent::class => 'onNotificationCanceled'
  23. ];
  24. }
  25. /**
  26. * @throws Exception
  27. */
  28. public function onNotificationCanceled(NotificationCanceledEvent $event)
  29. {
  30. $this->conversionEventService->handleConversionGoalReached(
  31. ConversionEventService::CAMPAIGN_ID_NOTIFICATION_CANCELLATION,
  32. $event->getNotificationId(),
  33. null,
  34. $event->getUser()
  35. );
  36. }
  37. }