<?php
namespace App\EventSubscriber;
use App\Service\Calendar\Rrule\RrulePostProcessService;
use App\Service\Sign\UserSignAlertService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\TerminateEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class KernelEventSubscriber implements EventSubscriberInterface
{
public function __construct(
private UserSignAlertService $userSignAlertService,
private RrulePostProcessService $rrulePostProcessService,
)
{
}
public static function getSubscribedEvents(): array
{
return [
KernelEvents::TERMINATE => '__invoke',
];
}
public function __invoke(TerminateEvent $terminateEvent): void
{
if ($this->rrulePostProcessService->shouldPostProcess()) {
$this->rrulePostProcessService->postProcess();
}
if ($this->userSignAlertService->shouldProcess()) {
$this->userSignAlertService->processAll();
}
}
}