[Routing] Fixed XML options resolution
This commit is contained in:
parent
b43cfc831d
commit
53a6ff88f7
@ -208,6 +208,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
$options = [];
|
$options = [];
|
||||||
$condition = null;
|
$condition = null;
|
||||||
|
|
||||||
|
/** @var \DOMElement $n */
|
||||||
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
|
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
|
||||||
if ($node !== $n->parentNode) {
|
if ($node !== $n->parentNode) {
|
||||||
continue;
|
continue;
|
||||||
@ -226,7 +227,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
$requirements[$n->getAttribute('key')] = trim($n->textContent);
|
$requirements[$n->getAttribute('key')] = trim($n->textContent);
|
||||||
break;
|
break;
|
||||||
case 'option':
|
case 'option':
|
||||||
$options[$n->getAttribute('key')] = trim($n->textContent);
|
$options[$n->getAttribute('key')] = XmlUtils::phpize(trim($n->textContent));
|
||||||
break;
|
break;
|
||||||
case 'condition':
|
case 'condition':
|
||||||
$condition = trim($n->textContent);
|
$condition = trim($n->textContent);
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<routes xmlns="http://symfony.com/schema/routing"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||||
|
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||||
|
|
||||||
|
<route id="app_utf8" path="/utf8">
|
||||||
|
<option key="utf8">true</option>
|
||||||
|
</route>
|
||||||
|
<route id="app_no_utf8" path="/no-utf8">
|
||||||
|
<option key="utf8">false</option>
|
||||||
|
</route>
|
||||||
|
</routes>
|
@ -83,6 +83,26 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUtf8Route()
|
||||||
|
{
|
||||||
|
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||||
|
$routeCollection = $loader->load('utf8.xml');
|
||||||
|
$routes = $routeCollection->all();
|
||||||
|
|
||||||
|
$this->assertCount(2, $routes, 'Two routes are loaded');
|
||||||
|
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||||
|
|
||||||
|
$utf8Route = $routeCollection->get('app_utf8');
|
||||||
|
|
||||||
|
$this->assertSame('/utf8', $utf8Route->getPath());
|
||||||
|
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');
|
||||||
|
|
||||||
|
$noUtf8Route = $routeCollection->get('app_no_utf8');
|
||||||
|
|
||||||
|
$this->assertSame('/no-utf8', $noUtf8Route->getPath());
|
||||||
|
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
* @dataProvider getPathsToInvalidFiles
|
* @dataProvider getPathsToInvalidFiles
|
||||||
|
Reference in New Issue
Block a user