Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f492ba5

Browse filesBrowse files
committed
feature #32695 [WebProfilerBundle] Decoupling TwigBundle and using the new ErrorRenderer mechanism (yceruto)
This PR was merged into the 4.4 branch. Discussion ---------- [WebProfilerBundle] Decoupling TwigBundle and using the new ErrorRenderer mechanism | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #31398 (comment) | License | MIT | Doc PR | - Commits ------- 846d3e0 Decoupling TwigBundle and using the new ErrorRenderer mechanism
2 parents fad4104 + 846d3e0 commit f492ba5
Copy full SHA for f492ba5

16 files changed

+92
-13
lines changed

‎UPGRADE-4.4.md

Copy file name to clipboardExpand all lines: UPGRADE-4.4.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Validator
237237
WebProfilerBundle
238238
-----------------
239239

240-
* Deprecated the `ExceptionController::templateExists()` method
240+
* Deprecated the `ExceptionController` class in favor of `ExceptionErrorController`
241241
* Deprecated the `TemplateManager::templateExists()` method
242242

243243
WebServerBundle

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,11 @@ Yaml
579579
* The parser is now stricter and will throw a `ParseException` when a
580580
mapping is found inside a multi-line string.
581581

582+
WebProfilerBundle
583+
-----------------
584+
585+
* Removed the `ExceptionController` class, use `ExceptionErrorController` instead.
586+
582587
WebServerBundle
583588
---------------
584589

‎src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* Added button to clear the ajax request tab
88
* Deprecated the `ExceptionController::templateExists()` method
99
* Deprecated the `TemplateManager::templateExists()` method
10+
* Deprecated the `ExceptionController` in favor of `ExceptionErrorController`
1011

1112
4.3.0
1213
-----

‎src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
use Twig\Error\LoaderError;
2121
use Twig\Loader\ExistsLoaderInterface;
2222

23+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ExceptionController::class, ExceptionErrorController::class), E_USER_DEPRECATED);
24+
2325
/**
2426
* ExceptionController.
2527
*
2628
* @author Fabien Potencier <fabien@symfony.com>
29+
*
30+
* @deprecated since Symfony 4.4, use the ExceptionErrorController instead.
2731
*/
2832
class ExceptionController
2933
{
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\WebProfilerBundle\Controller;
13+
14+
use Symfony\Component\ErrorRenderer\ErrorRenderer\HtmlErrorRenderer;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
17+
use Symfony\Component\HttpKernel\Profiler\Profiler;
18+
19+
/**
20+
* Renders the exception panel.
21+
*
22+
* @author Yonel Ceruto <yonelceruto@gmail.com>
23+
*/
24+
class ExceptionErrorController
25+
{
26+
private $htmlErrorRenderer;
27+
private $profiler;
28+
29+
public function __construct(HtmlErrorRenderer $htmlErrorRenderer, ?Profiler $profiler)
30+
{
31+
$this->htmlErrorRenderer = $htmlErrorRenderer;
32+
$this->profiler = $profiler;
33+
}
34+
35+
/**
36+
* Renders the exception panel stacktrace for the given token.
37+
*/
38+
public function body(string $token): Response
39+
{
40+
if (null === $this->profiler) {
41+
throw new NotFoundHttpException('The profiler must be enabled.');
42+
}
43+
44+
$exception = $this->profiler->loadProfile($token)
45+
->getCollector('exception')
46+
->getException()
47+
;
48+
49+
return new Response($this->htmlErrorRenderer->getBody($exception));
50+
}
51+
52+
/**
53+
* Renders the exception panel stylesheet.
54+
*/
55+
public function stylesheet(): Response
56+
{
57+
return new Response($this->htmlErrorRenderer->getStylesheet());
58+
}
59+
}

‎src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
<argument type="service" id="twig" />
2828
<argument>%kernel.debug%</argument>
2929
<argument type="service" id="debug.file_link_formatter" />
30-
<argument type="service" id="error_renderer.renderer.html" on-invalid="null" />
30+
<argument type="service" id="error_renderer.renderer.html" />
31+
<deprecated>The "%service_id%" service is deprecated since Symfony 4.4, use the "web_profiler.controller.exception_error" service instead.</deprecated>
32+
</service>
33+
34+
<service id="web_profiler.controller.exception_error" class="Symfony\Bundle\WebProfilerBundle\Controller\ExceptionErrorController" public="true">
35+
<argument type="service" id="error_renderer.renderer.html" />
36+
<argument type="service" id="profiler" on-invalid="null" />
3137
</service>
3238

3339
<service id="web_profiler.csp.handler" class="Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler">

‎src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
</route>
3838

3939
<route id="_profiler_exception" path="/{token}/exception">
40-
<default key="_controller">web_profiler.controller.exception::showAction</default>
40+
<default key="_controller">web_profiler.controller.exception_error::body</default>
4141
</route>
4242

4343
<route id="_profiler_exception_css" path="/{token}/exception.css">
44-
<default key="_controller">web_profiler.controller.exception::cssAction</default>
44+
<default key="_controller">web_profiler.controller.exception_error::stylesheet</default>
4545
</route>
4646

4747
</routes>

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{{ include('@Twig/exception.css.twig') }}
2-
31
.container {
42
max-width: auto;
53
margin: 0;

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{% if collector.hasexception %}
55
<style>
66
{{ render(path('_profiler_exception_css', { token: token })) }}
7+
{{ include('@WebProfiler/Collector/exception.css.twig') }}
78
</style>
89
{% endif %}
910
{{ parent() }}

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/messenger.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/messenger.html.twig
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
<span class="label status-error">exception</span>
120120
{% endif %}
121121
<a class="toggle-button">
122-
<span class="icon icon-close">{{ include('@Twig/images/icon-minus-square.svg') }}</span>
123-
<span class="icon icon-open">{{ include('@Twig/images/icon-plus-square.svg') }}</span>
122+
<span class="icon icon-close">{{ include('@WebProfiler/images/icon-minus-square.svg') }}</span>
123+
<span class="icon icon-open">{{ include('@WebProfiler/images/icon-plus-square.svg') }}</span>
124124
</a>
125125
</th>
126126
</tr>

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base.html.twig
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="{{ _charset }}" />
55
<meta name="robots" content="noindex,nofollow" />
66
<meta name="viewport" content="width=device-width,initial-scale=1" />
7-
<title>Symfony Profiler</title>
7+
<title>{% block title %}Symfony Profiler{% endblock %}</title>
88
<link rel="icon" type="image/x-icon" sizes="16x16" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFEUlEQVR4AZVXA4wm2RMf27bXDM/+3/+sYBGfrbVtezc6BWtzfPbYXtvDL9906t6v0vWl05me7q1JzXuvvu4yXnvZgJ9hH6bwZYXLFR739vauUGuDwhq1L1N4Uv/tRYUhFjwcg49hn6aYr1V4TiGp86CoP9Oh1tV414KnM6t9fHymKUZ3DAI0hW4b1AyK3lE8phh5OxWeoJgUGhi5mLm95YzBwcHuhIQEV1JSEoWGhoKWHxYWFmenhJ/B5W0GwZpDt5Ovry9lZWWRyWOu5ORk7JsUpogsq5gnmISTU+HKQoLFQv/qq6/os88+I+EVFRUlSsRZ5oRiVmwlXMWShQkahUdERJCfnx/vd+3aRTU1NXTixAmqrq6mK1eu0PTp05mnrmD+QK6XhLO0XP2O2FJAQICRjjMU4P1PP/1EfX19NGfOHM8Z0N7ezueQkBBXYGAgSWIaQ5Em2T5QzFNSUig9PV3OHOe4uDjZ87p//34C7Nm7x/NcRUUFAX799Vec8Y7m7+8Pz92SfBDXr7VwPYRbxn/MmDG8Tps2jQBd3V30/PPPe35/6qmnaPXq1TR69Gg+h4eHiwwosdLT4dBkQDSXWmJiIq/vv/8+/fvvv3ThwgWqr6+n/Px8oyCmAerq6jy03Nx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5ErkJggg==">
99

1010
{% block head %}

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_redirect.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_redirect.html.twig
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends '@Twig/layout.html.twig' %}
1+
{% extends '@WebProfiler/Profiler/base.html.twig' %}
22

33
{% block title 'Redirection Intercepted' %}
44

+1Lines changed: 1 addition & 0 deletions
Loading
+1Lines changed: 1 addition & 0 deletions
Loading

‎src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function setUp()
5454
$this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock();
5555

5656
$this->container = new ContainerBuilder();
57-
$this->container->register('error_renderer.renderer.html', HtmlErrorRenderer::class);
57+
$this->container->register('error_renderer.renderer.html', HtmlErrorRenderer::class)->setPublic(true);
5858
$this->container->register('event_dispatcher', EventDispatcher::class)->setPublic(true);
5959
$this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'))->setPublic(true);
6060
$this->container->register('twig', 'Twig\Environment')->setPublic(true);
@@ -92,10 +92,11 @@ public function testDefaultConfig($debug)
9292

9393
$extension = new WebProfilerExtension();
9494
$extension->load([[]], $this->container);
95+
$this->container->removeDefinition('web_profiler.controller.exception');
9596

9697
$this->assertFalse($this->container->has('web_profiler.debug_toolbar'));
9798

98-
$this->assertSaneContainer($this->getCompiledContainer());
99+
self::assertSaneContainer($this->getCompiledContainer());
99100
}
100101

101102
/**
@@ -105,10 +106,11 @@ public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listene
105106
{
106107
$extension = new WebProfilerExtension();
107108
$extension->load([['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]], $this->container);
109+
$this->container->removeDefinition('web_profiler.controller.exception');
108110

109111
$this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar'));
110112

111-
$this->assertSaneContainer($this->getCompiledContainer(), '', ['web_profiler.csp.handler']);
113+
self::assertSaneContainer($this->getCompiledContainer(), '', ['web_profiler.csp.handler']);
112114

113115
if ($listenerInjected) {
114116
$this->assertSame($listenerEnabled, $this->container->get('web_profiler.debug_toolbar')->isEnabled());

‎src/Symfony/Bundle/WebProfilerBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/composer.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"require": {
1919
"php": "^7.1.3",
2020
"symfony/config": "^4.2|^5.0",
21+
"symfony/error-renderer": "^4.4|^5.0",
2122
"symfony/http-kernel": "^4.4",
2223
"symfony/routing": "^3.4|^4.0|^5.0",
2324
"symfony/twig-bundle": "^4.2|^5.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.