diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
index e9650c7a9f..e19a764b05 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
@@ -193,7 +193,7 @@ class JsonDescriptor extends Descriptor
*/
protected function getRouteData(Route $route)
{
- return array(
+ $data = array(
'path' => $route->getPath(),
'pathRegex' => $route->compile()->getRegex(),
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
@@ -205,6 +205,12 @@ class JsonDescriptor extends Descriptor
'requirements' => $route->getRequirements() ?: 'NO CUSTOM',
'options' => $route->getOptions(),
);
+
+ if ('' !== $route->getCondition()) {
+ $data['condition'] = $route->getCondition();
+ }
+
+ return $data;
}
private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, bool $showArguments = false): array
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
index 9a93695e56..49f59eda92 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
@@ -60,6 +60,10 @@ class MarkdownDescriptor extends Descriptor
."\n".'- Requirements: '.($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
+ if ('' !== $route->getCondition()) {
+ $output .= "\n".'- Condition: '.$route->getCondition();
+ }
+
$this->write(isset($options['name'])
? $options['name']."\n".str_repeat('-', \strlen($options['name']))."\n\n".$output
: $output);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
index 90cd0e5254..5615069e21 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
@@ -92,6 +92,10 @@ class TextDescriptor extends Descriptor
array('Options', $this->formatRouterConfig($route->getOptions())),
);
+ if ('' !== $route->getCondition()) {
+ $tableRows[] = array('Condition', $route->getCondition());
+ }
+
$table = new Table($this->getOutput());
$table->setHeaders($tableHeaders)->setRows($tableRows);
$table->render();
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
index ead8fd3744..68b4a806cc 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
@@ -215,6 +215,11 @@ class XmlDescriptor extends Descriptor
}
}
+ if ('' !== $route->getCondition()) {
+ $routeXML->appendChild($hostXML = $dom->createElement('condition'));
+ $hostXML->appendChild(new \DOMText($route->getCondition()));
+ }
+
return $dom;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
index 666b77b30a..ccfe07e3d9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
@@ -53,7 +53,8 @@ class ObjectsProvider
array('opt1' => 'val1', 'opt2' => 'val2'),
'localhost',
array('http', 'https'),
- array('put', 'post')
+ array('put', 'post'),
+ "context.getMethod() in ['GET', 'HEAD', 'POST']"
),
);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json
index e190ef0cbf..5b70dde63a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json
@@ -12,5 +12,6 @@
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
"opt1": "val1",
"opt2": "val2"
- }
+ },
+ "condition": "context.getMethod() in ['GET', 'HEAD', 'POST']"
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md
index 1d776c5ffe..c60a6296b2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md
@@ -11,3 +11,4 @@
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
- `opt1`: val1
- `opt2`: val2
+- Condition: context.getMethod() in ['GET', 'HEAD', 'POST']
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt
index 5593cc0d81..5853dd013d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt
@@ -14,4 +14,5 @@
[39;49m| Options | compiler_class: Symfony\Component\Routing\RouteCompiler[39;49m[39;49m |[39;49m
[39;49m| | [39;49m[39;49mopt1: val1[39;49m[39;49m |[39;49m
[39;49m| | [39;49mopt2: val2 |
+| Condition | context.getMethod() in ['GET', 'HEAD', 'POST'] |
+--------------+-------------------------------------------------------------------+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml
index 584ab1b12d..f06a5f0cc3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml
@@ -11,4 +11,5 @@
+ context.getMethod() in ['GET', 'HEAD', 'POST']
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json
index bd60070ed5..200108a166 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json
@@ -33,6 +33,7 @@
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
"opt1": "val1",
"opt2": "val2"
- }
+ },
+ "condition": "context.getMethod() in ['GET', 'HEAD', 'POST']"
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md
index cbb70b4d31..432001f024 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md
@@ -34,4 +34,5 @@ route_2
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
- `opt1`: val1
- `opt2`: val2
+- Condition: context.getMethod() in ['GET', 'HEAD', 'POST']
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml
index 666a53730d..6a07e05964 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml
@@ -31,5 +31,6 @@
+ context.getMethod() in ['GET', 'HEAD', 'POST']