Skip to content

Commit 5c5c911

Browse files
committed
minor symfony#21021 [TwigBridge] Late deprecation for TwigRendererEngine::setEnvironment() (chalasr)
This PR was merged into the 3.3-dev branch. Discussion ---------- [TwigBridge] Late deprecation for TwigRendererEngine::setEnvironment() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | symfony#20093 (comment) | License | MIT | Doc PR | n/a This method should have been deprecated in 3.2 since the twig environment should be injected through the constructor and replacing it later can break things (see symfony#20093 (comment) for details). Maybe this could target 3.2 Commits ------- aabb73c Deprecate TwigRendererEngine::setEnvironment()
2 parents d73dd8b + aabb73c commit 5c5c911

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

UPGRADE-3.3.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ SecurityBundle
3838

3939
* The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0.
4040
Use the `getListeners()` method instead.
41+
42+
TwigBridge
43+
----------
44+
45+
* The `TwigRendererEngine::setEnvironment()` method has been deprecated and will be removed
46+
in 4.0. Pass the Twig Environment as second argument of the constructor instead.

UPGRADE-4.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ TwigBridge
220220
* The possibility to inject the Form Twig Renderer into the form extension
221221
has been removed. Inject it into the `TwigRendererEngine` instead.
222222

223+
* The `TwigRendererEngine::setEnvironment()` method has been removed.
224+
Pass the Twig Environment as second argument of the constructor instead.
225+
223226
Validator
224227
---------
225228

src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ public function __construct(array $defaultThemes = array(), \Twig_Environment $e
4141

4242
/**
4343
* {@inheritdoc}
44+
*
45+
* @deprecated since version 3.3, to be removed in 4.0
4446
*/
4547
public function setEnvironment(\Twig_Environment $environment)
4648
{
49+
if ($this->environment) {
50+
@trigger_error(sprintf('The "%s()" method is deprecated since version 3.3 and will be removed in 4.0. Pass the Twig Environment as second argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED);
51+
}
52+
4753
$this->environment = $environment;
4854
}
4955

0 commit comments

Comments
 (0)