src/Suez/UserRequestBundle/Controller/ExceptionController.php line 36

Open in your IDE?
  1. <?php
  2. /**
  3. * Copyright (C) SUEZ Smart Solutions - All Rights Reserved
  4. * On’Connect Gateway Management, 2018
  5. * Unauthorized copying of this file, via any medium is strictly prohibited
  6. * Proprietary and confidential
  7. * For the full copyright and license information, please report to the LICENSE CONTRACT.
  8. */
  9. namespace Suez\UserRequestBundle\Controller;
  10. use Skies\QRcodeBundle\DineshBarcode\DNS2D;
  11. use Symfony\Component\Debug\Exception\FlattenException;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
  15. /**
  16.  * Class ExceptionController.
  17.  */
  18. class ExceptionController extends \Symfony\Bundle\TwigBundle\Controller\ExceptionController
  19. {
  20.     /**
  21.      * Display exception page.
  22.      *
  23.      * @param Request                   $request
  24.      * @param FlattenException          $exception
  25.      * @param DebugLoggerInterface|null $logger
  26.      *
  27.      * @return Response
  28.      *
  29.      * @throws \Twig_Error_Loader
  30.      * @throws \Twig_Error_Runtime
  31.      * @throws \Twig_Error_Syntax
  32.      */
  33.     public function showAction(Request $requestFlattenException $exceptionDebugLoggerInterface $logger null)
  34.     {
  35.         // Create QR Code from error message.
  36.         $error   base64_encode(substr($exception->getMessage(), 01227) ?: 'Uncaught error 500');
  37.         $dns2d   = new DNS2D();
  38.         $barcode $dns2d->getBarcodeHTML($error'QRCODE,Q'33'black');
  39.         $currentContent $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
  40.         $code           $exception->getStatusCode();
  41.         return new Response($this->twig->render(
  42.             (string) $this->findTemplate($request$request->getRequestFormat(), $code$this->debug),
  43.             array(
  44.                 'status_code'    => $code,
  45.                 'status_text'    => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
  46.                 'exception'      => $exception,
  47.                 'logger'         => $logger,
  48.                 'currentContent' => $currentContent,
  49.                 'barcode'        => $barcode,
  50.             )
  51.         ));
  52.     }
  53. }