[TwigBundle] use the new Twig autoescaping strategy

This commit is contained in:
Fabien Potencier 2015-01-13 12:21:48 +01:00
parent bd01a29eb4
commit 55c4b41c29
6 changed files with 11 additions and 9 deletions

View File

@ -18,7 +18,7 @@
"require": {
"php": ">=5.3.9",
"doctrine/common": "~2.3",
"twig/twig": "~1.12,>=1.12.3",
"twig/twig": "~1.17",
"psr/log": "~1.0"
},
"replace": {

View File

@ -18,7 +18,7 @@
"require": {
"php": ">=5.3.9",
"symfony/security-csrf": "~2.6|~3.0.0",
"twig/twig": "~1.13,>=1.13.1"
"twig/twig": "~1.17"
},
"require-dev": {
"symfony/finder": "~2.3|~3.0.0",

View File

@ -166,9 +166,7 @@ class Configuration implements ConfigurationInterface
$rootNode
->fixXmlConfig('path')
->children()
->variableNode('autoescape')
->defaultValue(array('Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy', 'guess'))
->end()
->variableNode('autoescape')->defaultValue('filename')->end()
->scalarNode('autoescape_service')->defaultNull()->end()
->scalarNode('autoescape_service_method')->defaultNull()->end()
->scalarNode('base_template_class')->example('Twig_Template')->end()

View File

@ -149,7 +149,7 @@ class TwigExtensionTest extends TestCase
$this->compileContainer($container);
$options = $container->getParameter('twig.options');
$this->assertEquals(array('Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy', 'guess'), $options['autoescape']);
$this->assertEquals('filename', $options['autoescape']);
}
public function testGlobalsWithDifferentTypesAndValues()

View File

@ -11,8 +11,12 @@
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>
*
* @deprecated since version 2.7, will be removed in 3.0. Use the "filename" auto-escaping strategy instead.
*/
class TwigDefaultEscapingStrategy
{

View File

@ -54,13 +54,13 @@ class TwigEngine extends BaseEngine implements EngineInterface
/**
* @deprecated since version 2.7, to be removed in 3.0.
* Use TwigDefaultEscapingStrategy instead.
* Use the 'filename' strategy instead.
*/
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);
}
/**