[FrameworkBundle] Added the condition routing option to the debug router command
This commit is contained in:
parent
737726516e
commit
92bdc9b5f4
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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']"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -12,5 +12,6 @@
|
||||
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||
"opt1": "val1",
|
||||
"opt2": "val2"
|
||||
}
|
||||
},
|
||||
"condition": "context.getMethod() in ['GET', 'HEAD', 'POST']"
|
||||
}
|
||||
|
@ -11,3 +11,4 @@
|
||||
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
|
||||
- `opt1`: val1
|
||||
- `opt2`: val2
|
||||
- Condition: context.getMethod() in ['GET', 'HEAD', 'POST']
|
@ -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'] |
|
||||
+--------------+-------------------------------------------------------------------+
|
||||
|
@ -11,4 +11,5 @@
|
||||
<option key="opt1">val1</option>
|
||||
<option key="opt2">val2</option>
|
||||
</options>
|
||||
<condition>context.getMethod() in ['GET', 'HEAD', 'POST']</condition>
|
||||
</route>
|
||||
|
@ -33,6 +33,7 @@
|
||||
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||
"opt1": "val1",
|
||||
"opt2": "val2"
|
||||
}
|
||||
},
|
||||
"condition": "context.getMethod() in ['GET', 'HEAD', 'POST']"
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,5 @@ route_2
|
||||
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
|
||||
- `opt1`: val1
|
||||
- `opt2`: val2
|
||||
- Condition: context.getMethod() in ['GET', 'HEAD', 'POST']
|
||||
|
||||
|
@ -31,5 +31,6 @@
|
||||
<option key="opt1">val1</option>
|
||||
<option key="opt2">val2</option>
|
||||
</options>
|
||||
<condition>context.getMethod() in ['GET', 'HEAD', 'POST']</condition>
|
||||
</route>
|
||||
</routes>
|
||||
|
Reference in New Issue
Block a user