Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b4d5827

Browse filesBrowse files
committed
bug #20079 fixed Twig support for 1.26 and 2.0 (fabpot)
This PR was merged into the 2.7 branch. Discussion ---------- fixed Twig support for 1.26 and 2.0 | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Removes the deprecation notices for Twig 1.26. Commits ------- 24e9cf2 fixed Twig support for 1.26 and 2.0
2 parents da6c664 + 24e9cf2 commit b4d5827
Copy full SHA for b4d5827

16 files changed

+29
-28
lines changed

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"paragonie/random_compat": "~1.0",
2222
"symfony/polyfill-apcu": "~1.1",
2323
"symfony/polyfill-mbstring": "~1.1",
24-
"twig/twig": "~1.23|~2.0",
24+
"twig/twig": "~1.26|~2.0",
2525
"psr/log": "~1.0"
2626
},
2727
"replace": {

‎src/Symfony/Bridge/Twig/Node/FormThemeNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Node/FormThemeNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function compile(\Twig_Compiler $compiler)
3030
{
3131
$compiler
3232
->addDebugInfo($this)
33-
->write('$this->env->getExtension(\'form\')->renderer->setTheme(')
33+
->write('$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->setTheme(')
3434
->subcompile($this->getNode('form'))
3535
->raw(', ')
3636
->subcompile($this->getNode('resources'))

‎src/Symfony/Bridge/Twig/Node/RenderBlockNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Node/RenderBlockNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function compile(\Twig_Compiler $compiler)
2525
{
2626
$compiler->addDebugInfo($this);
2727
$arguments = iterator_to_array($this->getNode('arguments'));
28-
$compiler->write('$this->env->getExtension(\'form\')->renderer->renderBlock(');
28+
$compiler->write('$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->renderBlock(');
2929

3030
if (isset($arguments[0])) {
3131
$compiler->subcompile($arguments[0]);

‎src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SearchAndRenderBlockNode extends \Twig_Node_Expression_Function
1919
public function compile(\Twig_Compiler $compiler)
2020
{
2121
$compiler->addDebugInfo($this);
22-
$compiler->raw('$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(');
22+
$compiler->raw('$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(');
2323

2424
preg_match('/_([^_]+)$/', $this->getAttribute('name'), $matches);
2525

‎src/Symfony/Bridge/Twig/Node/StopwatchNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Node/StopwatchNode.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public function compile(\Twig_Compiler $compiler)
3232
->raw(' = ')
3333
->subcompile($this->getNode('name'))
3434
->write(";\n")
35-
->write("\$this->env->getExtension('stopwatch')->getStopwatch()->start(")
35+
->write("\$this->env->getExtension('Symfony\Bridge\Twig\Extension\StopwatchExtension')->getStopwatch()->start(")
3636
->subcompile($this->getNode('var'))
3737
->raw(", 'template');\n")
3838
->subcompile($this->getNode('body'))
39-
->write("\$this->env->getExtension('stopwatch')->getStopwatch()->stop(")
39+
->write("\$this->env->getExtension('Symfony\Bridge\Twig\Extension\StopwatchExtension')->getStopwatch()->stop(")
4040
->subcompile($this->getNode('var'))
4141
->raw(");\n")
4242
;

‎src/Symfony/Bridge/Twig/Node/TransNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Node/TransNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function compile(\Twig_Compiler $compiler)
5454
$method = !$this->hasNode('count') ? 'trans' : 'transChoice';
5555

5656
$compiler
57-
->write('echo $this->env->getExtension(\'translator\')->getTranslator()->'.$method.'(')
57+
->write('echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->'.$method.'(')
5858
->subcompile($msg)
5959
;
6060

‎src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testCompile()
4545

4646
$this->assertEquals(
4747
sprintf(
48-
'$this->env->getExtension(\'form\')->renderer->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"));',
48+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"));',
4949
$this->getVariableGetter('form')
5050
),
5151
trim($compiler->compile($node)->getSource())
@@ -57,7 +57,7 @@ public function testCompile()
5757

5858
$this->assertEquals(
5959
sprintf(
60-
'$this->env->getExtension(\'form\')->renderer->setTheme(%s, "tpl1");',
60+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->setTheme(%s, "tpl1");',
6161
$this->getVariableGetter('form')
6262
),
6363
trim($compiler->compile($node)->getSource())

‎src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testCompileWidget()
2727

2828
$this->assertEquals(
2929
sprintf(
30-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'widget\')',
30+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'widget\')',
3131
$this->getVariableGetter('form')
3232
),
3333
trim($compiler->compile($node)->getSource())
@@ -50,7 +50,7 @@ public function testCompileWidgetWithVariables()
5050

5151
$this->assertEquals(
5252
sprintf(
53-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'widget\', array("foo" => "bar"))',
53+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'widget\', array("foo" => "bar"))',
5454
$this->getVariableGetter('form')
5555
),
5656
trim($compiler->compile($node)->getSource())
@@ -70,7 +70,7 @@ public function testCompileLabelWithLabel()
7070

7171
$this->assertEquals(
7272
sprintf(
73-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\', array("label" => "my label"))',
73+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\', array("label" => "my label"))',
7474
$this->getVariableGetter('form')
7575
),
7676
trim($compiler->compile($node)->getSource())
@@ -92,7 +92,7 @@ public function testCompileLabelWithNullLabel()
9292
// Otherwise the default label is overwritten with null.
9393
$this->assertEquals(
9494
sprintf(
95-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\')',
95+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\')',
9696
$this->getVariableGetter('form')
9797
),
9898
trim($compiler->compile($node)->getSource())
@@ -114,7 +114,7 @@ public function testCompileLabelWithEmptyStringLabel()
114114
// Otherwise the default label is overwritten with null.
115115
$this->assertEquals(
116116
sprintf(
117-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\')',
117+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\')',
118118
$this->getVariableGetter('form')
119119
),
120120
trim($compiler->compile($node)->getSource())
@@ -133,7 +133,7 @@ public function testCompileLabelWithDefaultLabel()
133133

134134
$this->assertEquals(
135135
sprintf(
136-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\')',
136+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\')',
137137
$this->getVariableGetter('form')
138138
),
139139
trim($compiler->compile($node)->getSource())
@@ -160,7 +160,7 @@ public function testCompileLabelWithAttributes()
160160
// https://github.com/symfony/symfony/issues/5029
161161
$this->assertEquals(
162162
sprintf(
163-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\', array("foo" => "bar"))',
163+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\', array("foo" => "bar"))',
164164
$this->getVariableGetter('form')
165165
),
166166
trim($compiler->compile($node)->getSource())
@@ -186,7 +186,7 @@ public function testCompileLabelWithLabelAndAttributes()
186186

187187
$this->assertEquals(
188188
sprintf(
189-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in argument"))',
189+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in argument"))',
190190
$this->getVariableGetter('form')
191191
),
192192
trim($compiler->compile($node)->getSource())
@@ -217,7 +217,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
217217
// https://github.com/symfony/symfony/issues/5029
218218
$this->assertEquals(
219219
sprintf(
220-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))',
220+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))',
221221
$this->getVariableGetter('form')
222222
),
223223
trim($compiler->compile($node)->getSource())
@@ -254,7 +254,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
254254
// https://github.com/symfony/symfony/issues/5029
255255
$this->assertEquals(
256256
sprintf(
257-
'$this->env->getExtension(\'form\')->renderer->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in attributes") + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))',
257+
'$this->env->getExtension(\'Symfony\Bridge\Twig\Extension\FormExtension\')->renderer->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in attributes") + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))',
258258
$this->getVariableGetter('form')
259259
),
260260
trim($compiler->compile($node)->getSource())

‎src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testCompileStrict()
2929

3030
$this->assertEquals(
3131
sprintf(
32-
'echo $this->env->getExtension(\'translator\')->getTranslator()->trans("trans %%var%%", array_merge(array("%%var%%" => %s), %s), "messages");',
32+
'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->trans("trans %%var%%", array_merge(array("%%var%%" => %s), %s), "messages");',
3333
$this->getVariableGetterWithoutStrictCheck('var'),
3434
$this->getVariableGetterWithStrictCheck('foo')
3535
),

‎src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function setPrefix($prefix)
8282

8383
protected function extractTemplate($template, MessageCatalogue $catalogue)
8484
{
85-
$visitor = $this->twig->getExtension('translator')->getTranslationNodeVisitor();
85+
$visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor();
8686
$visitor->enable();
8787

8888
$this->twig->parse($this->twig->tokenize($template));

‎src/Symfony/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.3.9",
20-
"twig/twig": "~1.23|~2.0"
20+
"twig/twig": "~1.26|~2.0"
2121
},
2222
"require-dev": {
2323
"symfony/asset": "~2.7",

‎src/Symfony/Bundle/SecurityBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"symfony/yaml": "~2.0,>=2.0.5",
3838
"symfony/expression-language": "~2.6",
3939
"doctrine/doctrine-bundle": "~1.2",
40-
"twig/twig": "~1.23|~2.0",
40+
"twig/twig": "~1.26|~2.0",
4141
"ircmaxell/password-compat": "~1.0"
4242
},
4343
"autoload": {

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public function __construct($dateFormat, $intervalFormat, $timezone, $decimals,
3737

3838
public function configure(\Twig_Environment $environment)
3939
{
40-
$environment->getExtension('core')->setDateFormat($this->dateFormat, $this->intervalFormat);
40+
$environment->getExtension('Twig_Extension_Core')->setDateFormat($this->dateFormat, $this->intervalFormat);
4141

4242
if (null !== $this->timezone) {
43-
$environment->getExtension('core')->setTimezone($this->timezone);
43+
$environment->getExtension('Twig_Extension_Core')->setTimezone($this->timezone);
4444
}
4545

46-
$environment->getExtension('core')->setNumberFormat($this->decimals, $this->decimalPoint, $this->thousandsSeparator);
46+
$environment->getExtension('Twig_Extension_Core')->setNumberFormat($this->decimals, $this->decimalPoint, $this->thousandsSeparator);
4747
}
4848
}

‎src/Symfony/Bundle/TwigBundle/Node/RenderNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Node/RenderNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function compile(\Twig_Compiler $compiler)
3434
{
3535
$compiler
3636
->addDebugInfo($this)
37-
->write("echo \$this->env->getExtension('actions')->renderUri(")
37+
->write("echo \$this->env->getExtension('Symfony\Bundle\TwigBundle\Extension\ActionsExtension')->renderUri(")
3838
->subcompile($this->getNode('expr'))
3939
->raw(', ')
4040
->subcompile($this->getNode('options'))

‎src/Symfony/Bundle/TwigBundle/TwigEngine.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/TwigEngine.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function setDefaultEscapingStrategy($strategy)
4949
{
5050
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Inject the escaping strategy in the Twig_Environment object instead.', E_USER_DEPRECATED);
5151

52-
$this->environment->getExtension('escaper')->setDefaultStrategy($strategy);
52+
$this->environment->getExtension('Twig_Extension_Escaper')->setDefaultStrategy($strategy);
5353
}
5454

5555
/**

‎src/Symfony/Bundle/TwigBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/composer.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"php": ">=5.3.9",
2020
"symfony/asset": "~2.7",
2121
"symfony/twig-bridge": "~2.7",
22+
"twig/twig": "~1.26|~2.0",
2223
"symfony/http-foundation": "~2.5",
2324
"symfony/http-kernel": "~2.7"
2425
},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.