Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86805e0

Browse files
committed
bug symfony#58198 [TwigBundle] Add support for resetting globals between HTTP requests (fabpot)
This PR was merged into the 5.4 branch. Discussion ---------- [TwigBundle] Add support for resetting globals between HTTP requests | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes-ish | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | License | MIT See twigphp/Twig#4007 and twigphp/Twig#4286 Commits ------- 42eb115 [TwigBundle] Add support for resetting globals between HTTP requests
2 parents d7000e6 + 42eb115 commit 86805e0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\Mailer\Mailer;
2525
use Symfony\Component\Translation\Translator;
2626
use Symfony\Contracts\Service\ResetInterface;
27+
use Twig\Environment;
2728
use Twig\Extension\ExtensionInterface;
2829
use Twig\Extension\RuntimeExtensionInterface;
2930
use Twig\Loader\LoaderInterface;
@@ -45,6 +46,10 @@ public function load(array $configs, ContainerBuilder $container)
4546
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
4647
$loader->load('twig.php');
4748

49+
if (method_exists(Environment::class, 'resetGlobals')) {
50+
$container->getDefinition('twig')->addTag('kernel.reset', ['method' => 'resetGlobals']);
51+
}
52+
4853
if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'], true)) {
4954
$loader->load('form.php');
5055

0 commit comments

Comments
 (0)