Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb1a4b7

Browse files
committed
[TwigBundle] do not lose already set method calls
1 parent c18c93b commit cb1a4b7

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function process(ContainerBuilder $container)
9191
$twigLoader = $container->getDefinition('twig.loader.native_filesystem');
9292
if ($container->has('templating')) {
9393
$loader = $container->getDefinition('twig.loader.filesystem');
94-
$loader->setMethodCalls($twigLoader->getMethodCalls());
94+
$loader->setMethodCalls(array_merge($twigLoader->getMethodCalls(), $loader->getMethodCalls()));
9595

9696
$twigLoader->clearTag('twig.loader');
9797
} else {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler;
13+
14+
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Definition;
17+
18+
class ExtensionPassTest extends \PHPUnit_Framework_TestCase
19+
{
20+
public function testProcessDoesNotDropExistingFileLoaderMethodCalls()
21+
{
22+
$container = new ContainerBuilder();
23+
$container->setParameter('kernel.debug', false);
24+
25+
$container->register('twig.app_variable', '\Symfony\Bridge\Twig\AppVariable');
26+
$container->register('templating', '\Symfony\Bundle\TwigBundle\TwigEngine');
27+
28+
$nativeTwigLoader = new Definition('\Twig_Loader_Filesystem');
29+
$nativeTwigLoader->addMethodCall('addPath', array());
30+
$container->setDefinition('twig.loader.native_filesystem', $nativeTwigLoader);
31+
32+
$filesystemLoader = new Definition('\Symfony\Bundle\TwigBundle\Loader\FilesystemLoader');
33+
$filesystemLoader->addMethodCall('addPath', array());
34+
$container->setDefinition('twig.loader.filesystem', $filesystemLoader);
35+
36+
$extensionPass = new ExtensionPass();
37+
$extensionPass->process($container);
38+
39+
$this->assertCount(2, $filesystemLoader->getMethodCalls());
40+
}
41+
}

0 commit comments

Comments
 (0)