[HttpKernel] fix registering IDE links

This commit is contained in:
Nicolas Grekas 2018-05-28 17:16:05 +02:00
parent 6fc7fdb182
commit 92e3023195
4 changed files with 6 additions and 5 deletions

View File

@ -61,9 +61,6 @@ class FrameworkBundle extends Bundle
{ {
public function boot() public function boot()
{ {
if (!ini_get('xdebug.file_link_format') && !get_cfg_var('xdebug.file_link_format')) {
ini_set('xdebug.file_link_format', $this->container->getParameter('debug.file_link_format'));
}
ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true); ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true);
if ($this->container->hasParameter('kernel.trusted_proxies')) { if ($this->container->hasParameter('kernel.trusted_proxies')) {

View File

@ -74,6 +74,7 @@
<argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="logger" on-invalid="null" />
<argument>%kernel.debug%</argument> <argument>%kernel.debug%</argument>
<argument>%kernel.charset%</argument> <argument>%kernel.charset%</argument>
<argument>%debug.file_link_format%</argument>
</service> </service>
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener"> <service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">

View File

@ -30,6 +30,7 @@ class ExceptionController
protected $twig; protected $twig;
protected $debug; protected $debug;
protected $profiler; protected $profiler;
private $fileLinkFormat;
public function __construct(Profiler $profiler = null, Environment $twig, $debug, FileLinkFormatter $fileLinkFormat = null) public function __construct(Profiler $profiler = null, Environment $twig, $debug, FileLinkFormatter $fileLinkFormat = null)
{ {

View File

@ -36,13 +36,15 @@ class ExceptionListener implements EventSubscriberInterface
protected $logger; protected $logger;
protected $debug; protected $debug;
private $charset; private $charset;
private $fileLinkFormat;
public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null) public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null, $fileLinkFormat = null)
{ {
$this->controller = $controller; $this->controller = $controller;
$this->logger = $logger; $this->logger = $logger;
$this->debug = $debug; $this->debug = $debug;
$this->charset = $charset; $this->charset = $charset;
$this->fileLinkFormat = $fileLinkFormat;
} }
public function onKernelException(GetResponseForExceptionEvent $event) public function onKernelException(GetResponseForExceptionEvent $event)
@ -123,7 +125,7 @@ class ExceptionListener implements EventSubscriberInterface
$attributes = array( $attributes = array(
'exception' => $exception = FlattenException::create($exception), 'exception' => $exception = FlattenException::create($exception),
'_controller' => $this->controller ?: function () use ($exception) { '_controller' => $this->controller ?: function () use ($exception) {
$handler = new ExceptionHandler($this->debug, $this->charset); $handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat);
return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders()); return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
}, },