bug #33620 [Twig] Fix Twig config extra keys (fabpot)

This PR was merged into the 3.4 branch.

Discussion
----------

[Twig] Fix Twig config extra keys

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

Instead of `unsetting` keys, I know pass explicitly which key we need (right now, as we don't unset everything, there are a bunch of info passed to Environment that should not be there).

Commits
-------

e2043ff53e [Twig] Fix Twig config extra keys
This commit is contained in:
Fabien Potencier 2019-09-18 10:30:21 +02:00
commit 212f66827b

View File

@ -150,18 +150,20 @@ class TwigExtension extends Extension
}
}
unset(
$config['form'],
$config['globals'],
$config['extensions']
);
if (isset($config['autoescape_service']) && isset($config['autoescape_service_method'])) {
$config['autoescape'] = [new Reference($config['autoescape_service']), $config['autoescape_service_method']];
}
unset($config['autoescape_service'], $config['autoescape_service_method']);
$container->getDefinition('twig')->replaceArgument(1, $config);
$container->getDefinition('twig')->replaceArgument(1, array_intersect_key($config, [
'debug' => true,
'charset' => true,
'base_template_class' => true,
'strict_variables' => true,
'autoescape' => true,
'cache' => true,
'auto_reload' => true,
'optimizations' => true,
]));
$container->registerForAutoconfiguration(\Twig_ExtensionInterface::class)->addTag('twig.extension');
$container->registerForAutoconfiguration(\Twig_LoaderInterface::class)->addTag('twig.loader');