Skip to content

Commit 3e66f5b

Browse files
committed
bug #9197 [FrameworkBundle] updated XML route description (jfsimon)
This PR was merged into the master branch. Discussion ---------- [FrameworkBundle] updated XML route description This PR turns ```xml <route name="route_1" path="/hello/{name}" class="Symfony\Component\Routing\Route" path_regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s"> ``` into ```xml <route name="route_1" class="Symfony\Component\Routing\Route"> <path regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">/hello/{name}</path> ``` in XML routing description. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7887 | License | MIT | Doc PR | n/a Commits ------- 7b99ede [FrameworkBundle] updated XML route description
2 parents e4c2393 + bb8bdd5 commit 3e66f5b

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Console/Descriptor/XmlDescriptor.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ private function getRouteDocument(Route $route, $name = null)
128128
$routeXML->setAttribute('name', $name);
129129
}
130130

131-
$routeXML->setAttribute('path', $route->getPath());
132131
$routeXML->setAttribute('class', get_class($route));
133-
$routeXML->setAttribute('path_regex', $route->compile()->getRegex());
132+
133+
$routeXML->appendChild($pathXML = $dom->createElement('path'));
134+
$pathXML->setAttribute('regex', $route->compile()->getRegex());
135+
$pathXML->appendChild(new \DOMText($route->getPath()));
134136

135137
if ('' !== $route->getHost()) {
136138
$routeXML->appendChild($hostXML = $dom->createElement('host'));

Tests/Fixtures/Descriptor/route_1.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<route path="/hello/{name}" class="Symfony\Component\Routing\Route" path_regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">
2+
<route class="Symfony\Component\Routing\Route">
3+
<path regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">/hello/{name}</path>
34
<host regex="#^localhost$#s">localhost</host>
45
<scheme>http</scheme>
56
<scheme>https</scheme>

Tests/Fixtures/Descriptor/route_2.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<route path="/name/add" class="Symfony\Component\Routing\Route" path_regex="#^/name/add$#s">
2+
<route class="Symfony\Component\Routing\Route">
3+
<path regex="#^/name/add$#s">/name/add</path>
34
<host regex="#^localhost$#s">localhost</host>
45
<scheme>http</scheme>
56
<scheme>https</scheme>

Tests/Fixtures/Descriptor/route_collection_1.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<routes>
3-
<route name="route_1" path="/hello/{name}" class="Symfony\Component\Routing\Route" path_regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">
3+
<route name="route_1" class="Symfony\Component\Routing\Route">
4+
<path regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">/hello/{name}</path>
45
<host regex="#^localhost$#s">localhost</host>
56
<scheme>http</scheme>
67
<scheme>https</scheme>
@@ -18,7 +19,8 @@
1819
<option key="opt2">val2</option>
1920
</options>
2021
</route>
21-
<route name="route_2" path="/name/add" class="Symfony\Component\Routing\Route" path_regex="#^/name/add$#s">
22+
<route name="route_2" class="Symfony\Component\Routing\Route">
23+
<path regex="#^/name/add$#s">/name/add</path>
2224
<host regex="#^localhost$#s">localhost</host>
2325
<scheme>http</scheme>
2426
<scheme>https</scheme>

0 commit comments

Comments
 (0)