Skip to content

Commit 819bb29

Browse files
committed
bug symfony#9719 [TwigBundle] fix configuration tree for paths (mdavis1982, cordoval)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes symfony#9719). Discussion ---------- [TwigBundle] fix configuration tree for paths | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#8171 | License | MIT | Doc PR | na This is a joint effort with @mdavis1982 and @cordoval 👶 pairing up and warming for hacking day in Warsaw Commits ------- 9aa88e4 added regression test 4201d41 fix issue symfony#8171 on configuration tree for twig extension -- pairing up with @cordoval
2 parents d15fe34 + 9aa88e4 commit 819bb29

File tree

9 files changed

+34
-10
lines changed

9 files changed

+34
-10
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode)
136136
->scalarNode('optimizations')->end()
137137
->arrayNode('paths')
138138
->normalizeKeys(false)
139+
->useAttributeAsKey('paths')
139140
->beforeNormalization()
140141
->always()
141142
->then(function ($paths) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('twig', array(
4+
'paths' => array(
5+
'namespaced_path3' => 'namespace3',
6+
),
7+
));

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'paths' => array(
2323
'path1',
2424
'path2',
25-
'namespaced_path1' => 'namespace',
26-
'namespaced_path2' => 'namespace',
25+
'namespaced_path1' => 'namespace1',
26+
'namespaced_path2' => 'namespace2',
2727
),
2828
));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:twig="http://symfony.com/schema/dic/twig"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd">
8+
9+
<twig:config auto-reload="true" autoescape="true" base-template-class="stdClass" cache="/tmp" charset="ISO-8859-1" debug="true" strict-variables="true">
10+
<twig:path namespace="namespace3">namespaced_path3</twig:path>
11+
</twig:config>
12+
</container>

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<twig:global key="pi">3.14</twig:global>
1616
<twig:path>path1</twig:path>
1717
<twig:path>path2</twig:path>
18-
<twig:path namespace="namespace">namespaced_path1</twig:path>
19-
<twig:path namespace="namespace">namespaced_path2</twig:path>
18+
<twig:path namespace="namespace1">namespaced_path1</twig:path>
19+
<twig:path namespace="namespace2">namespaced_path2</twig:path>
2020
</twig:config>
2121
</container>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
twig:
2+
paths:
3+
namespaced_path3: namespace3

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ twig:
1717
paths:
1818
path1: ''
1919
path2: ''
20-
namespaced_path1: namespace
21-
namespaced_path2: namespace
20+
namespaced_path1: namespace1
21+
namespaced_path2: namespace2

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function testTwigLoaderPaths($format)
145145
$container = $this->createContainer();
146146
$container->registerExtension(new TwigExtension());
147147
$this->loadFromFile($container, 'full', $format);
148+
$this->loadFromFile($container, 'extra', $format);
148149
$this->compileContainer($container);
149150

150151
$def = $container->getDefinition('twig.loader.filesystem');
@@ -160,8 +161,9 @@ public function testTwigLoaderPaths($format)
160161
$this->assertEquals(array(
161162
array('path1'),
162163
array('path2'),
163-
array('namespaced_path1', 'namespace'),
164-
array('namespaced_path2', 'namespace'),
164+
array('namespaced_path1', 'namespace1'),
165+
array('namespaced_path2', 'namespace2'),
166+
array('namespaced_path3', 'namespace3'),
165167
array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'),
166168
array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'),
167169
array(__DIR__.'/Fixtures/Resources/views'),

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
class FinderTest extends Iterator\RealIteratorTestCase
1818
{
19-
2019
public function testCreate()
2120
{
2221
$this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create());
@@ -796,7 +795,7 @@ function (Adapter\AdapterInterface $adapter) {
796795
);
797796
}
798797

799-
/**
798+
/**
800799
* Searching in multiple locations with sub directories involves
801800
* AppendIterator which does an unnecessary rewind which leaves
802801
* FilterIterator with inner FilesystemIterator in an invalid state.

0 commit comments

Comments
 (0)