[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)
|
protected function getRouteData(Route $route)
|
||||||
{
|
{
|
||||||
return array(
|
$data = array(
|
||||||
'path' => $route->getPath(),
|
'path' => $route->getPath(),
|
||||||
'pathRegex' => $route->compile()->getRegex(),
|
'pathRegex' => $route->compile()->getRegex(),
|
||||||
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
|
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
|
||||||
@ -205,6 +205,12 @@ class JsonDescriptor extends Descriptor
|
|||||||
'requirements' => $route->getRequirements() ?: 'NO CUSTOM',
|
'requirements' => $route->getRequirements() ?: 'NO CUSTOM',
|
||||||
'options' => $route->getOptions(),
|
'options' => $route->getOptions(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ('' !== $route->getCondition()) {
|
||||||
|
$data['condition'] = $route->getCondition();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, bool $showArguments = false): array
|
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".'- Requirements: '.($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')
|
||||||
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
|
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
|
||||||
|
|
||||||
|
if ('' !== $route->getCondition()) {
|
||||||
|
$output .= "\n".'- Condition: '.$route->getCondition();
|
||||||
|
}
|
||||||
|
|
||||||
$this->write(isset($options['name'])
|
$this->write(isset($options['name'])
|
||||||
? $options['name']."\n".str_repeat('-', \strlen($options['name']))."\n\n".$output
|
? $options['name']."\n".str_repeat('-', \strlen($options['name']))."\n\n".$output
|
||||||
: $output);
|
: $output);
|
||||||
|
@ -92,6 +92,10 @@ class TextDescriptor extends Descriptor
|
|||||||
array('Options', $this->formatRouterConfig($route->getOptions())),
|
array('Options', $this->formatRouterConfig($route->getOptions())),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ('' !== $route->getCondition()) {
|
||||||
|
$tableRows[] = array('Condition', $route->getCondition());
|
||||||
|
}
|
||||||
|
|
||||||
$table = new Table($this->getOutput());
|
$table = new Table($this->getOutput());
|
||||||
$table->setHeaders($tableHeaders)->setRows($tableRows);
|
$table->setHeaders($tableHeaders)->setRows($tableRows);
|
||||||
$table->render();
|
$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;
|
return $dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ class ObjectsProvider
|
|||||||
array('opt1' => 'val1', 'opt2' => 'val2'),
|
array('opt1' => 'val1', 'opt2' => 'val2'),
|
||||||
'localhost',
|
'localhost',
|
||||||
array('http', 'https'),
|
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",
|
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||||
"opt1": "val1",
|
"opt1": "val1",
|
||||||
"opt2": "val2"
|
"opt2": "val2"
|
||||||
}
|
},
|
||||||
|
"condition": "context.getMethod() in ['GET', 'HEAD', 'POST']"
|
||||||
}
|
}
|
||||||
|
@ -11,3 +11,4 @@
|
|||||||
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
|
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
|
||||||
- `opt1`: val1
|
- `opt1`: val1
|
||||||
- `opt2`: val2
|
- `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| 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;49m[39;49mopt1: val1[39;49m[39;49m |[39;49m
|
||||||
[39;49m| | [39;49mopt2: val2 |
|
[39;49m| | [39;49mopt2: val2 |
|
||||||
|
| Condition | context.getMethod() in ['GET', 'HEAD', 'POST'] |
|
||||||
+--------------+-------------------------------------------------------------------+
|
+--------------+-------------------------------------------------------------------+
|
||||||
|
@ -11,4 +11,5 @@
|
|||||||
<option key="opt1">val1</option>
|
<option key="opt1">val1</option>
|
||||||
<option key="opt2">val2</option>
|
<option key="opt2">val2</option>
|
||||||
</options>
|
</options>
|
||||||
|
<condition>context.getMethod() in ['GET', 'HEAD', 'POST']</condition>
|
||||||
</route>
|
</route>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||||
"opt1": "val1",
|
"opt1": "val1",
|
||||||
"opt2": "val2"
|
"opt2": "val2"
|
||||||
}
|
},
|
||||||
|
"condition": "context.getMethod() in ['GET', 'HEAD', 'POST']"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,5 @@ route_2
|
|||||||
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
|
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
|
||||||
- `opt1`: val1
|
- `opt1`: val1
|
||||||
- `opt2`: val2
|
- `opt2`: val2
|
||||||
|
- Condition: context.getMethod() in ['GET', 'HEAD', 'POST']
|
||||||
|
|
||||||
|
@ -31,5 +31,6 @@
|
|||||||
<option key="opt1">val1</option>
|
<option key="opt1">val1</option>
|
||||||
<option key="opt2">val2</option>
|
<option key="opt2">val2</option>
|
||||||
</options>
|
</options>
|
||||||
|
<condition>context.getMethod() in ['GET', 'HEAD', 'POST']</condition>
|
||||||
</route>
|
</route>
|
||||||
</routes>
|
</routes>
|
||||||
|
Reference in New Issue
Block a user