vendor/simpledot/edm-bundle/AWEdmBundle/EventListener/CacheResponseListener.php line 28

Open in your IDE?
  1. <?php
  2. namespace AWEdmBundle\EventListener;
  3. use AppBundle\Entity\User;
  4. use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationFailureResponse;
  5. use Psr\Container\ContainerInterface;
  6. use Symfony\Component\HttpFoundation\JsonResponse;
  7. use Symfony\Component\HttpFoundation\RedirectResponse;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
  10. use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
  11. use Symfony\Component\HttpFoundation\Cookie;
  12. use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  13. use Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface;
  14. /**
  15.  * Allow to reset token if user-token changed
  16.  */
  17. class CacheResponseListener
  18. {
  19.     /**
  20.      * @param FilterResponseEvent $event
  21.      * @throws \Psr\Container\ContainerExceptionInterface
  22.      * @throws \Psr\Container\NotFoundExceptionInterface
  23.      */
  24.     public function onKernelResponse(FilterResponseEvent $event)
  25.     {
  26.         $response $event->getResponse();
  27.         if($response->headers->has('Static-Cms') and $response->headers->get('Static-Cms') == 'true'){
  28.             $response->setSharedMaxAge(604800);
  29.             $response->setMaxAge(604800);
  30.             $response->headers->removeCacheControlDirective('must-revalidate');
  31.         }
  32.     }
  33. }