8000 Merge branch '2.7' · symfony/symfony@f5a2fa7 · GitHub
[go: up one dir, main page]

Skip to content

Commit f5a2fa7

Browse files
committed
Merge branch '2.7'
* 2.7: [TwigBundle] added some missing deprecation notices [TwigBundle] use the new Twig autoescaping strategy exit when Twig environment is not set [HttpKernel] fixed missing use cases fixed typo moved AppVariable to the bridge Conflicts: src/Symfony/Bridge/Twig/composer.json
2 parents a7e038b + 8d12652 commit f5a2fa7

File tree

13 files changed

+75
-20
lines changed

13 files changed

+75
-20
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"doctrine/common": "~2.3",
21-
"twig/twig": "~1.12,>=1.12.3",
21+
"twig/twig": "~1.17",
2222
"psr/log": "~1.0"
2323
},
2424
"replace": {

src/Symfony/Bundle/TwigBundle/AppVariable.php renamed to src/Symfony/Bridge/Twig/AppVariable.php

Lines changed: 1 addition & 1 deletion
Or 8000 iginal file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bundle\TwigBundle;
12+
namespace Symfony\Bridge\Twig;
1313

1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\RequestStack;

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ protected function configure()
8383
protected function execute(InputInterface $input, OutputInterface $output)
8484
{
8585
$twig = $this->getTwigEnvironment();
86+
87+
if (null === $twig) {
88+
$output->writeln('<error>The Twig environment needs to be set.</error>');
89+
90+
return 1;
91+
}
92+
8693
$types = array('functions', 'filters', 'tests', 'globals');
8794

8895
if ($input->getOption('format') === 'json') {

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"symfony/security-csrf": "~2.7|~3.0",
21-
"twig/twig": "~1.13,>=1.13.1"
21+
"twig/twig": "~1.17"
2222
},
2323
"require-dev": {
2424
"symfony/finder": "~2.7|~3.0",

src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414
use Symfony\Bridge\Twig\Command\DebugCommand as BaseDebugCommand;
1515
use Symfony\Component\DependencyInjection\ContainerInterface;
1616
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
17-
use Symfony\Component\Console\Input\InputArgument;
18-
use Symfony\Component\Console\Input\InputOption;
19-
use Symfony\Component\Console\Input\InputInterface;
20-
use Symfony\Component\Console\Output\OutputInterface;
2117

2218
/**
2319
* Lists twig functions, filters, globals and tests present in the current project
2420
*
2521
* @author Jordi Boggiano <j.boggiano@seld.be>
2622
*/
27-
class DebugCommand extends BaseLintCommand implements ContainerAwareInterface
23+
class DebugCommand extends BaseDebugCommand implements ContainerAwareInterface
2824
{
2925
/**
3026
* @var ContainerInterface|null

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode)
166166
$rootNode
167167
->fixXmlConfig('path')
168168
->children()
169-
->variableNode('autoescape')
170-
->defaultValue(array('Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy', 'guess'))
171-
->end()
169+
->variableNode('autoescape')->defaultValue('filename')->end()
172170
->scalarNode('autoescape_service')->defaultNull()->end()
173171
->scalarNode('autoescape_service_method')->defaultNull()->end()
174172
->scalarNode('base_template_class')->example('Twig_Template')->end()

src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function __construct($handler)
5656
*/
5757
public function renderUri($uri, array $options = array())
5858
{
59+
trigger_error('The Twig render tag was deprecated in version 2.2 and will be removed in version 3.0. Use the Twig render function instead.', E_USER_DEPRECATED);
60+
5961
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
6062
unset($options['strategy']);
6163

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</call>
3939
</service>
4040

41-
<service id="twig.app_variable" class="Symfony\Bundle\TwigBundle\AppVariable" public="false">
41+
<service id="twig.app_variable" class="Symfony\Bridge\Twig\AppVariable" public="false">
4242
<call method="setEnvironment"><argument>%kernel.environment%</argument></call>
4343
<call method="setDebug"><argument>%kernel.debug%</argument></call>
4444
<call method="setSecurity"><argument type="service" id="security.context" on-invalid="ignore" /></call>

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function testLoadDefaultTemplateEscapingGuesserConfiguration($format)
149149
$this->compileContainer($container);
150150

151151
$options = $container->getParameter('twig.options');
152-
$this->assertEquals(array('Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy', 'guess'), $options['autoescape']);
152+
$this->assertEquals('filename', $options['autoescape']);
153153
}
154154

155155
public function testGlobalsWithDifferentTypesAndValues()

src/Symfony/Bundle/TwigBundle/TwigDefaultEscapingStrategy.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111

1212
namespace Symfony\Bundle\TwigBundle;
1313

14+
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);
15+
1416
/**
1517
* @author Fabien Potencier <fabien@symfony.com>
18+
*
19+
* @deprecated since version 2.7, will be removed in 3.0. Use the "filename" auto-escaping strategy instead.
1620
*/
1721
class TwigDefaultEscapingStrategy
1822
{

src/Symfony/Bundle/TwigBundle/TwigEngine.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public function setDefaultEscapingStrategy($strategy)
5454

5555
/**
5656
* @deprecated since version 2.7, to be removed in 3.0.
57-
* Use TwigDefaultEscapingStrategy instead.
57+
* Use the 'filename' strategy instead.
5858
*/
5959
public function guessDefaultEscapingStrategy($filename)
6060
{
61-
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);
61+
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);
6262

63-
return TwigDefaultEscapingStrategy::guess($filename);
63+
return \Twig_FileExtensionEscapingStrategy::guess($filename);
6464
}
6565

6666
/**

src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public function process(ContainerBuilder $container)
6060

6161
foreach ($tags as $tag) {
6262
if (!isset($tag['alias'])) {
63-
trigger_error(sprintf('Service "%s" will have to define the "alias" attribute on the "%s" tag as of Symfony 3.0.', $id, $this->fragmentTag), E_USER_DEPRECATED);
63+
trigger_error(sprintf('Service "%s" will have to define the "alias" attribute on the "%s" tag as of Symfony 3.0.', $id, $this->rendererTag), E_USER_DEPRECATED);
6464

6565
// register the handler as a non-lazy-loaded one
6666
$definition->addMethodCall('addRenderer', array(new Reference($id)));
67+
} else {
68+
$definition->addMethodCall('addRendererService', array($tag['alias'], $id));
6769
}
68-
69-
$definition->addMethodCall('addRendererService', array($tag['alias'], $id));
7070
}
7171
}
7272
}

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,60 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
1313

14+
use Symfony\Component\DependencyInjection\Reference;
1415
use Symfony\Component\HttpFoundation\Request;
1516
use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
1617
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
1718

1819
class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
1920
{
21+
public function testLegacyFragmentRedererWithoutAlias()
22+
{
23+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
24+
25+
// no alias
26+
$services = array(
27+
'my_content_renderer' => array(array()),
28+
);
29+
30+
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
31+
$renderer
32+
->expects($this->once())
33+
->method('addMethodCall')
34+
->with('addRenderer', array(new Reference('my_content_renderer')))
35+
;
36+
37+
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
38+
$definition->expects($this->atLeastOnce())
39+
->method('getClass')
40+
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
41+
$definition
42+
->expects($this->once())
43+
->method('isPublic')
44+
->will($this->returnValue(true))
45+
;
46+
47+
$builder = $this->getMock(
48+
'Symfony\Component\DependencyInjection\ContainerBuilder',
49+
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
50+
);
51+
$builder->expects($this->any())
52+
->method('hasDefinition')
53+
->will($this->returnValue(true));
54+
55+
// We don't test kernel.fragment_renderer here
56+
$builder->expects($this->atLeastOnce())
57+
->method('findTaggedServiceIds')
58+
->will($this->returnValue($services));
59+
60+
$builder->expects($this->atLeastOnce())
61+
->method('getDefinition')
62+
->will($this->onConsecutiveCalls($renderer, $definition));
63+
64+
$pass = new FragmentRendererPass();
65+
$pass->process($builder);
66+
}
67+
2068
/**
2169
* Tests that content rendering not implementing FragmentRendererInterface
2270
* trigger an exception.
@@ -27,7 +75,7 @@ public function testContentRendererWithoutInterface()
2775
{
2876
// one service, not implementing any interface
2977
$services = array(
30-
'my_content_renderer' => array('alias' => 'foo'),
78+
'my_content_renderer' => array(array('alias' => 'foo')),
3179
);
3280

3381
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');

0 commit comments

Comments
 (0)
0