<?php
declare(strict_types=1);
namespace App\Bundles\UserBundle\EventListener;
use App\Bundles\EpidemiologicalSurveillanceBundle\Service\SurveillanceTemplateDeleteService;
use App\Bundles\UserBundle\Event\UsersBlockedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class UsersBlockedListener implements EventSubscriberInterface
{
public function __construct(
private readonly SurveillanceTemplateDeleteService $surveillanceTemplateDeleteService,
) {
}
public static function getSubscribedEvents(): array
{
return [
UsersBlockedEvent::NAME => 'onUsersBlocked',
];
}
public function onUsersBlocked(UsersBlockedEvent $event): void
{
$this->deleteSharedSurveillanceTemplates($event);
}
private function deleteSharedSurveillanceTemplates(UsersBlockedEvent $event): void
{
$this->surveillanceTemplateDeleteService->deleteAllShared($event->getIds());
}
}