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 b860ec3

Browse filesBrowse files
bug #21285 [TwigBundle] do not lose already set method calls (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] do not lose already set method calls | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21281 | License | MIT | Doc PR | Commits ------- cb1a4b7 [TwigBundle] do not lose already set method calls
2 parents c18c93b + cb1a4b7 commit b860ec3
Copy full SHA for b860ec3

File tree

2 files changed

+42
-1
lines changed
Filter options

2 files changed

+42
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php
+1-1Lines 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 {
+41Lines 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 <fabien@symfony.com>
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.