src/EventSubscriber/CacheabilitySubscriber.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  5. use Symfony\Component\HttpKernel\KernelEvents;
  6. class CacheabilitySubscriber implements EventSubscriberInterface
  7. {
  8.     public function onResponse(ResponseEvent $event): void
  9.     {
  10.         if ('sonata_admin_dashboard' === $event->getRequest()->get('_route')) {
  11.             $event->getResponse()->headers->set(
  12.                 'Cache-Control',
  13.                 'no-cache, max-age=0, must-revalidate, no-store'
  14.             );
  15.         }
  16.     }
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [KernelEvents::RESPONSE => [['onResponse'20]]];
  20.     }
  21. }