<?php
declare(strict_types=1);
namespace App\Event;
use App\Event\AccountEventToContactsEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use App\Services\ContactEvent\ContactEventService;
class AccountEventToContactsSubscriber implements EventSubscriberInterface
{
protected ContactEventService $contactEventService;
public function __construct(ContactEventService $contactEventService)
{
$this->contactEventService = $contactEventService;
}
public static function getSubscribedEvents()
{
return [
AccountEventToContactsEvent::NAME => 'onAccountEvent',
];
}
public function onAccountEvent(AccountEventToContactsEvent $event): void
{
$this->contactEventService->copyAccountEventItemToContact(
$event->getEventAccount(),
$event->getContactIds()
);
}
}