<?php
/**
* Copyright (C) SUEZ Smart Solutions - All Rights Reserved
* On’Connect Gateway Management, 2018
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* For the full copyright and license information, please report to the LICENSE CONTRACT.
*/
namespace Suez\UserRequestBundle\Controller;
use Skies\QRcodeBundle\DineshBarcode\DNS2D;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
/**
* Class ExceptionController.
*/
class ExceptionController extends \Symfony\Bundle\TwigBundle\Controller\ExceptionController
{
/**
* Display exception page.
*
* @param Request $request
* @param FlattenException $exception
* @param DebugLoggerInterface|null $logger
*
* @return Response
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
{
// Create QR Code from error message.
$error = base64_encode(substr($exception->getMessage(), 0, 1227) ?: 'Uncaught error 500');
$dns2d = new DNS2D();
$barcode = $dns2d->getBarcodeHTML($error, 'QRCODE,Q', 3, 3, 'black');
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$code = $exception->getStatusCode();
return new Response($this->twig->render(
(string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
'barcode' => $barcode,
)
));
}
}