Skip to content

Commit bbbbc6f

Browse files
Merge branch '3.4' into 4.2
* 3.4: [Cache] Only delete one key at a time when on Predis + Cluster [Validator] Add missing translations for Swedish locale [Routing] removed a useless var [Routing] Fixed XML options resolution
2 parents dfc89b2 + d8b1e23 commit bbbbc6f

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

Loader/PhpFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function load($file, $type = null)
4848

4949
if (\is_object($result) && \is_callable($result)) {
5050
$collection = new RouteCollection();
51-
$result(new RoutingConfigurator($collection, $this, $path, $file), $this);
51+
$result(new RoutingConfigurator($collection, $this, $path, $file));
5252
} else {
5353
$collection = $result;
5454
}

Loader/XmlFileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private function parseConfigs(\DOMElement $node, $path)
268268
$prefixes = [];
269269
$paths = [];
270270

271+
/** @var \DOMElement $n */
271272
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
272273
if ($node !== $n->parentNode) {
273274
continue;
@@ -292,7 +293,7 @@ private function parseConfigs(\DOMElement $node, $path)
292293
$requirements[$n->getAttribute('key')] = trim($n->textContent);
293294
break;
294295
case 'option':
295-
$options[$n->getAttribute('key')] = trim($n->textContent);
296+
$options[$n->getAttribute('key')] = XmlUtils::phpize(trim($n->textContent));
296297
break;
297298
case 'condition':
298299
$condition = trim($n->textContent);

Tests/Fixtures/localized/utf8.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<routes xmlns="http://symfony.com/schema/routing"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/routing
5+
http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<route id="app_utf8" path="/utf8">
8+
<option key="utf8">true</option>
9+
</route>
10+
<route id="app_no_utf8" path="/no-utf8">
11+
<option key="utf8">false</option>
12+
</route>
13+
</routes>

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ public function testLoadWithImport()
8383
}
8484
}
8585

86+
public function testUtf8Route()
87+
{
88+
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
89+
$routeCollection = $loader->load('utf8.xml');
90+
$routes = $routeCollection->all();
91+
92+
$this->assertCount(2, $routes, 'Two routes are loaded');
93+
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
94+
95+
$utf8Route = $routeCollection->get('app_utf8');
96+
97+
$this->assertSame('/utf8', $utf8Route->getPath());
98+
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');
99+
100+
$noUtf8Route = $routeCollection->get('app_no_utf8');
101+
102+
$this->assertSame('/no-utf8', $noUtf8Route->getPath());
103+
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
104+
}
105+
86106
public function testLoadLocalized()
87107
{
88108
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));

0 commit comments

Comments
 (0)