<?php
namespace App\Services;
use Doctrine\DBAL\Exception as DBALException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Doctrine\DBAL\Driver\Exception as DriverException;
class ExceptionsListener
{
public function onPdoException(ExceptionEvent $event)
{
$exception = $event->getThrowable();
if ($exception instanceof DriverException || $exception instanceof DBALException) {
$content = '<h1>Le site est en maintenance</h1><h2>A bientôt sur Whiplay !</h2>';
$content .= '<h1>The site is under maintenance</h1><h2>See you soon on Whiplay !</h2>';
$response = new Response($content);
$event->setResponse($response);
}
}
}