vendor/nellapp/sdk-bundle/src/Twig/Controller/ErrorController.php line 18

Open in your IDE?
  1. <?php
  2. namespace Nellapp\Bundle\SDKBundle\Twig\Controller;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  5. use Twig\Environment;
  6. class ErrorController
  7. {
  8.     private Environment $twig;
  9.     public function __construct(Environment $twig)
  10.     {
  11.         $this->twig $twig;
  12.     }
  13.     public function show(\Throwable $exception): Response
  14.     {
  15.         $statusCode $exception instanceof HttpExceptionInterface
  16.             $exception->getStatusCode()
  17.             : 500;
  18.         $template "@NellappSDK/Exception/error{$statusCode}.html.twig";
  19.         if (!$this->twig->getLoader()->exists($template)) {
  20.             $template "@NellappSDK/Exception/error.html.twig";
  21.         }
  22.         return new Response(
  23.             $this->twig->render($template, [
  24.                 'exception' => $exception,
  25.                 'status_code' => $statusCode,
  26.             ]),
  27.             $statusCode
  28.         );
  29.     }
  30. }