<?php
declare(strict_types=1);
namespace App\Event;
use App\Event\CampaignUpdateHistoryEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use App\Services\Campaign\CampaignUpdateHistoryService;
class CampaignUpdateHistorySubscriber implements EventSubscriberInterface
{
protected CampaignUpdateHistoryService $campaignUpdateHistoryService;
public function __construct(CampaignUpdateHistoryService $campaignUpdateHistoryService)
{
$this->campaignUpdateHistoryService = $campaignUpdateHistoryService;
}
public static function getSubscribedEvents()
{
return [
CampaignUpdateHistoryEvent::NAME => 'onCampaignUpdate',
];
}
public function onCampaignUpdate(CampaignUpdateHistoryEvent $event): void
{
$this->campaignUpdateHistoryService->saveCampaignUpdateHistory(
$event->getCampaign(),
$event->getUser()
);
}
}