<?php
namespace App\EventSubscriber;
use App\Service\ProfileCtrService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class KernelSubscriber implements EventSubscriberInterface
{
public function __construct(
private ProfileCtrService $profileCtrService
) {}
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => 'clearCtrShowsSession',
KernelEvents::TERMINATE => 'updateProfilesShowsAndPreviews',
];
}
public function updateProfilesShowsAndPreviews(KernelEvent $event): void
{
$this->profileCtrService->persistCtrDataToAppCache();
}
public function clearCtrShowsSession(KernelEvent $event): void
{
$this->profileCtrService->clearSession();
}
}