<?php
namespace App\EventSubscriber\App;
use App\Event\NotificationCanceledEvent;
use App\Service\ConversionEventService;
use App\Service\NotificationService;
use Exception;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class NotificationEventSubscriber implements EventSubscriberInterface
{
/** @var NotificationService */
private $notificationService;
/** @var ConversionEventService */
private $conversionEventService;
public function __construct(NotificationService $notificationService, ConversionEventService $conversionEventService)
{
$this->notificationService = $notificationService;
$this->conversionEventService = $conversionEventService;
}
public static function getSubscribedEvents()
{
return [
NotificationCanceledEvent::class => 'onNotificationCanceled'
];
}
/**
* @throws Exception
*/
public function onNotificationCanceled(NotificationCanceledEvent $event)
{
$this->conversionEventService->handleConversionGoalReached(
ConversionEventService::CAMPAIGN_ID_NOTIFICATION_CANCELLATION,
$event->getNotificationId(),
null,
$event->getUser()
);
}
}