src/EventSubscriber/KernelSubscriber.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Service\ProfileCtrService;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpKernel\Event\KernelEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. class KernelSubscriber implements EventSubscriberInterface
  8. {
  9.     public function __construct(
  10.         private ProfileCtrService $profileCtrService
  11.     ) {}
  12.     public static function getSubscribedEvents(): array
  13.     {
  14.         return [
  15.             KernelEvents::REQUEST => 'clearCtrShowsSession',
  16.             KernelEvents::TERMINATE => 'updateProfilesShowsAndPreviews',
  17.         ];
  18.     }
  19.     public function updateProfilesShowsAndPreviews(KernelEvent $event): void
  20.     {
  21.         $this->profileCtrService->persistCtrDataToAppCache();
  22.     }
  23.     public function clearCtrShowsSession(KernelEvent $event): void
  24.     {
  25.         $this->profileCtrService->clearSession();
  26.     }
  27. }