Skip to content

Commit d3c17f2

Browse files
committed
feature #32462 [WebProfilerBundle] Deprecating templateExists method (yceruto)
This PR was merged into the 4.4 branch. Discussion ---------- [WebProfilerBundle] Deprecating templateExists method | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | not needed Follow up #32458, so in 5.0 we can remove these methods safely. I'm not deprecating the `Symfony\Bundle\TwigBundle\Controller\ExceptionController::templateExists()` method because the whole class is being deprecated in #31398 See also #32461 Commits ------- 2e81e45 Deprecating templateExists method
2 parents 8935ea5 + 2e81e45 commit d3c17f2

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

UPGRADE-4.4.md

+6
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,9 @@ Validator
137137
when the `min` option is used.
138138
Set it to `true` to keep the current behavior and `false` to reject empty strings.
139139
In 5.0, it'll become optional and will default to `false`.
140+
141+
WebProfilerBundle
142+
-----------------
143+
144+
* Deprecated the `ExceptionController::templateExists()` method
145+
* Deprecated the `TemplateManager::templateExists()` method

UPGRADE-5.0.md

+6
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ Validator
477477
* The `egulias/email-validator` component is now required for using the `Email` constraint in strict mode
478478
* The `symfony/expression-language` component is now required for using the `Expression` constraint
479479

480+
WebProfilerBundle
481+
-----------------
482+
483+
* Removed the `ExceptionController::templateExists()` method
484+
* Removed the `TemplateManager::templateExists()` method
485+
480486
Workflow
481487
--------
482488

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ CHANGELOG
44
4.4.0
55
-----
66

7-
* Added button to clear the ajax request tab
7+
* Added button to clear the ajax request tab
8+
* Deprecated the `ExceptionController::templateExists()` method
9+
* Deprecated the `TemplateManager::templateExists()` method
810

911
4.3.0
1012
-----

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function cssAction($token)
101101

102102
$template = $this->getTemplate();
103103

104-
if (!$this->templateExists($template)) {
104+
if (!$this->templateExists($template, false)) {
105105
return new Response($this->errorRenderer->getStylesheet(), 200, ['Content-Type' => 'text/css']);
106106
}
107107

@@ -113,9 +113,15 @@ protected function getTemplate()
113113
return '@Twig/Exception/'.($this->debug ? 'exception' : 'error').'.html.twig';
114114
}
115115

116-
// to be removed when the minimum required version of Twig is >= 2.0
117-
protected function templateExists($template)
116+
/**
117+
* @deprecated since Symfony 4.4
118+
*/
119+
protected function templateExists($template/*, bool $triggerDeprecation = true */)
118120
{
121+
if (1 === \func_num_args()) {
122+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, use the "exists()" method of the Twig loader instead.', __METHOD__), E_USER_DEPRECATED);
123+
}
124+
119125
$loader = $this->twig->getLoader();
120126
if ($loader instanceof ExistsLoaderInterface) {
121127
return $loader->exists($template);

src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Twig\Error\LoaderError;
1919
use Twig\Loader\ExistsLoaderInterface;
2020
use Twig\Loader\SourceContextLoaderInterface;
21-
use Twig\Template;
2221

2322
/**
2423
* Profiler Templates Manager.
@@ -86,7 +85,7 @@ public function getNames(Profile $profile)
8685
$template = substr($template, 0, -10);
8786
}
8887

89-
if (!$this->templateExists($template.'.html.twig')) {
88+
if (!$this->templateExists($template.'.html.twig', false)) {
9089
throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
9190
}
9291

@@ -96,9 +95,15 @@ public function getNames(Profile $profile)
9695
return $templates;
9796
}
9897

99-
// to be removed when the minimum required version of Twig is >= 2.0
100-
protected function templateExists($template)
98+
/**
99+
* @deprecated since Symfony 4.4
100+
*/
101+
protected function templateExists($template/*, bool $triggerDeprecation = true */)
101102
{
103+
if (1 === \func_num_args()) {
104+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, use the "exists()" method of the Twig loader instead.', __METHOD__), E_USER_DEPRECATED);
105+
}
106+
102107
$loader = $this->twig->getLoader();
103108
if ($loader instanceof ExistsLoaderInterface) {
104109
return $loader->exists($template);

0 commit comments

Comments
 (0)