Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

34 rindas
1008B

  1. <?php
  2. namespace Lc\SovBundle\EventListener;
  3. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  4. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  5. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  6. class ExceptionListener
  7. {
  8. public function __construct(
  9. SessionInterface $session
  10. ) {
  11. $this->session = $session;
  12. }
  13. public function onKernelException(ExceptionEvent $event)
  14. {
  15. // You get the exception object from the received event
  16. $exception = $event->getThrowable();
  17. // On détecte une erreur interne (500), on remove les sessions qui servent de filtre dans l'admin
  18. if ($exception instanceof HttpExceptionInterface != true) {
  19. if (!headers_sent()) {
  20. foreach ($this->session->all() as $key => $s) {
  21. if (str_contains($key, "_filter")) {
  22. $this->session->remove($key);
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }