src/Services/ExceptionsListener.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Services;
  3. use Doctrine\DBAL\Exception as DBALException;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  6. use Doctrine\DBAL\Driver\Exception as DriverException;
  7. class ExceptionsListener
  8. {
  9.     public function onPdoException(ExceptionEvent $event)
  10.     {
  11.         $exception $event->getThrowable();
  12.         if ($exception instanceof DriverException || $exception instanceof DBALException) {
  13.             $content '<h1>Le site est en maintenance</h1><h2>A bientôt sur Whiplay !</h2>';
  14.             $content .= '<h1>The site is under maintenance</h1><h2>See you soon on Whiplay !</h2>';
  15.             $response = new Response($content);
  16.             $event->setResponse($response);
  17.         }
  18.     }
  19. }