feature #13401 [TwigBundle] use the new Twig autoescaping strategy (fabpot)
This PR was merged into the 2.7 branch.
Discussion
----------
[TwigBundle] use the new Twig autoescaping strategy
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
55c4b41
[TwigBundle] use the new Twig autoescaping strategy
This commit is contained in:
commit
8d12652162
@ -18,7 +18,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.9",
|
"php": ">=5.3.9",
|
||||||
"doctrine/common": "~2.3",
|
"doctrine/common": "~2.3",
|
||||||
"twig/twig": "~1.12,>=1.12.3",
|
"twig/twig": "~1.17",
|
||||||
"psr/log": "~1.0"
|
"psr/log": "~1.0"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.9",
|
"php": ">=5.3.9",
|
||||||
"symfony/security-csrf": "~2.6|~3.0.0",
|
"symfony/security-csrf": "~2.6|~3.0.0",
|
||||||
"twig/twig": "~1.13,>=1.13.1"
|
"twig/twig": "~1.17"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/finder": "~2.3|~3.0.0",
|
"symfony/finder": "~2.3|~3.0.0",
|
||||||
|
@ -166,9 +166,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
$rootNode
|
$rootNode
|
||||||
->fixXmlConfig('path')
|
->fixXmlConfig('path')
|
||||||
->children()
|
->children()
|
||||||
->variableNode('autoescape')
|
->variableNode('autoescape')->defaultValue('filename')->end()
|
||||||
->defaultValue(array('Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy', 'guess'))
|
|
||||||
->end()
|
|
||||||
->scalarNode('autoescape_service')->defaultNull()->end()
|
->scalarNode('autoescape_service')->defaultNull()->end()
|
||||||
->scalarNode('autoescape_service_method')->defaultNull()->end()
|
->scalarNode('autoescape_service_method')->defaultNull()->end()
|
||||||
->scalarNode('base_template_class')->example('Twig_Template')->end()
|
->scalarNode('base_template_class')->example('Twig_Template')->end()
|
||||||
|
@ -149,7 +149,7 @@ class TwigExtensionTest extends TestCase
|
|||||||
$this->compileContainer($container);
|
$this->compileContainer($container);
|
||||||
|
|
||||||
$options = $container->getParameter('twig.options');
|
$options = $container->getParameter('twig.options');
|
||||||
$this->assertEquals(array('Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy', 'guess'), $options['autoescape']);
|
$this->assertEquals('filename', $options['autoescape']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGlobalsWithDifferentTypesAndValues()
|
public function testGlobalsWithDifferentTypesAndValues()
|
||||||
|
@ -11,8 +11,12 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\TwigBundle;
|
namespace Symfony\Bundle\TwigBundle;
|
||||||
|
|
||||||
|
trigger_error('The '.__NAMESPACE__.'\TwigDefaultEscapingStrategy class is deprecated in version 2.7 and will be removed in version 3.0. Use the "filename" auto-escaping strategy instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* @deprecated since version 2.7, will be removed in 3.0. Use the "filename" auto-escaping strategy instead.
|
||||||
*/
|
*/
|
||||||
class TwigDefaultEscapingStrategy
|
class TwigDefaultEscapingStrategy
|
||||||
{
|
{
|
||||||
|
@ -54,13 +54,13 @@ class TwigEngine extends BaseEngine implements EngineInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated since version 2.7, to be removed in 3.0.
|
* @deprecated since version 2.7, to be removed in 3.0.
|
||||||
* Use TwigDefaultEscapingStrategy instead.
|
* Use the 'filename' strategy instead.
|
||||||
*/
|
*/
|
||||||
public function guessDefaultEscapingStrategy($filename)
|
public function guessDefaultEscapingStrategy($filename)
|
||||||
{
|
{
|
||||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Use the Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy::guess method instead.', E_USER_DEPRECATED);
|
trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Use the Twig_FileExtensionEscapingStrategy::guess method instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
return TwigDefaultEscapingStrategy::guess($filename);
|
return \Twig_FileExtensionEscapingStrategy::guess($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user