Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf492ba5

Browse 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 parentsfad4104 +846d3e0 commitf492ba5

File tree

16 files changed

+92
-13
lines changed

16 files changed

+92
-13
lines changed

‎UPGRADE-4.4.md‎

Lines 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‎

Lines 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‎

Lines 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‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
useTwig\Error\LoaderError;
2121
useTwig\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
{
Lines 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+
namespaceSymfony\Bundle\WebProfilerBundle\Controller;
13+
14+
useSymfony\Component\ErrorRenderer\ErrorRenderer\HtmlErrorRenderer;
15+
useSymfony\Component\HttpFoundation\Response;
16+
useSymfony\Component\HttpKernel\Exception\NotFoundHttpException;
17+
useSymfony\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+
publicfunction__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+
publicfunctionbody(string$token):Response
39+
{
40+
if (null ===$this->profiler) {
41+
thrownewNotFoundHttpException('The profiler must be enabled.');
42+
}
43+
44+
$exception =$this->profiler->loadProfile($token)
45+
->getCollector('exception')
46+
->getException()
47+
;
48+
49+
returnnewResponse($this->htmlErrorRenderer->getBody($exception));
50+
}
51+
52+
/**
53+
* Renders the exception panel stylesheet.
54+
*/
55+
publicfunctionstylesheet():Response
56+
{
57+
returnnewResponse($this->htmlErrorRenderer->getStylesheet());
58+
}
59+
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
<argumenttype="service"id="twig" />
2828
<argument>%kernel.debug%</argument>
2929
<argumenttype="service"id="debug.file_link_formatter" />
30-
<argumenttype="service"id="error_renderer.renderer.html"on-invalid="null" />
30+
<argumenttype="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+
<serviceid="web_profiler.controller.exception_error"class="Symfony\Bundle\WebProfilerBundle\Controller\ExceptionErrorController"public="true">
35+
<argumenttype="service"id="error_renderer.renderer.html" />
36+
<argumenttype="service"id="profiler"on-invalid="null" />
3137
</service>
3238

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
</route>
3838

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

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

4747
</routes>

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

Lines 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‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{%ifcollector.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‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
<spanclass="label status-error">exception</span>
120120
{%endif %}
121121
<aclass="toggle-button">
122-
<spanclass="icon icon-close">{{include('@Twig/images/icon-minus-square.svg') }}</span>
123-
<spanclass="icon icon-open">{{include('@Twig/images/icon-plus-square.svg') }}</span>
122+
<spanclass="icon icon-close">{{include('@WebProfiler/images/icon-minus-square.svg') }}</span>
123+
<spanclass="icon icon-open">{{include('@WebProfiler/images/icon-plus-square.svg') }}</span>
124124
</a>
125125
</th>
126126
</tr>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp