vendor/symfony/web-profiler-bundle/Controller/ExceptionPanelController.php line 57

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <[email protected]>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\WebProfilerBundle\Controller;
  11. use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  14. use Symfony\Component\HttpKernel\Profiler\Profiler;
  15. /**
  16.  * Renders the exception panel.
  17.  *
  18.  * @author Yonel Ceruto <[email protected]>
  19.  *
  20.  * @internal
  21.  */
  22. class ExceptionPanelController
  23. {
  24.     private $errorRenderer;
  25.     private $profiler;
  26.     public function __construct(HtmlErrorRenderer $errorRendererProfiler $profiler null)
  27.     {
  28.         $this->errorRenderer $errorRenderer;
  29.         $this->profiler $profiler;
  30.     }
  31.     /**
  32.      * Renders the exception panel stacktrace for the given token.
  33.      */
  34.     public function body(string $token): Response
  35.     {
  36.         if (null === $this->profiler) {
  37.             throw new NotFoundHttpException('The profiler must be enabled.');
  38.         }
  39.         $exception $this->profiler->loadProfile($token)
  40.             ->getCollector('exception')
  41.             ->getException()
  42.         ;
  43.         return new Response($this->errorRenderer->getBody($exception), 200, ['Content-Type' => 'text/html']);
  44.     }
  45.     /**
  46.      * Renders the exception panel stylesheet.
  47.      */
  48.     public function stylesheet(): Response
  49.     {
  50.         return new Response($this->errorRenderer->getStylesheet(), 200, ['Content-Type' => 'text/css']);
  51.     }
  52. }