bug #13421 [FrameworkBundle] fix routing descriptor for options (Tobion)

This PR was merged into the 2.5 branch.

Discussion
----------

[FrameworkBundle] fix routing descriptor for options

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

The markdown descriptor for routes missed brackets, so that the `options` where actually ignored. Also fixed some other inconsistencies.

Commits
-------

b0c29a0 [FrameworkBundle] fix routing descriptor for options
This commit is contained in:
Fabien Potencier 2015-01-15 13:14:56 +01:00
commit b53ceb1fb6
7 changed files with 29 additions and 9 deletions

View File

@ -56,7 +56,7 @@ class MarkdownDescriptor extends Descriptor
."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')
."\n".'- Class: '.get_class($route)
."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults())
."\n".'- Requirements: '.$this->formatRouterConfig($requirements) ?: 'NONE'
."\n".'- Requirements: '.($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM')
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
$this->write(isset($options['name'])

View File

@ -79,7 +79,7 @@ class TextDescriptor extends Descriptor
'<comment>Method</comment> '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'),
'<comment>Class</comment> '.get_class($route),
'<comment>Defaults</comment> '.$this->formatRouterConfig($route->getDefaults()),
'<comment>Requirements</comment> '.$this->formatRouterConfig($requirements) ?: 'NO CUSTOM',
'<comment>Requirements</comment> '.($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM'),
'<comment>Options</comment> '.$this->formatRouterConfig($route->getOptions()),
);
@ -306,6 +306,10 @@ class TextDescriptor extends Descriptor
*/
private function formatRouterConfig(array $array)
{
if (!count($array)) {
return 'NONE';
}
$string = '';
ksort($array);
foreach ($array as $name => $value) {

View File

@ -8,4 +8,8 @@
- Defaults:
- `name`: Joseph
- Requirements:
- `name`: [a-z]+
- `name`: [a-z]+
- Options:
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
- `opt1`: val1
- `opt2`: val2

View File

@ -9,4 +9,4 @@
<comment>Requirements</comment> name: [a-z]+
<comment>Options</comment> compiler_class: Symfony\Component\Routing\RouteCompiler
opt1: val1
opt2: val2
opt2: val2

View File

@ -6,4 +6,8 @@
- Method: PUT|POST
- Class: Symfony\Component\Routing\Route
- Defaults: NONE
- Requirements: NONE
- Requirements: NO CUSTOM
- Options:
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
- `opt1`: val1
- `opt2`: val2

View File

@ -5,8 +5,8 @@
<comment>Scheme</comment> http|https
<comment>Method</comment> PUT|POST
<comment>Class</comment> Symfony\Component\Routing\Route
<comment>Defaults</comment>
<comment>Requirements</comment>
<comment>Defaults</comment> NONE
<comment>Requirements</comment> NO CUSTOM
<comment>Options</comment> compiler_class: Symfony\Component\Routing\RouteCompiler
opt1: val1
opt2: val2
opt2: val2

View File

@ -12,6 +12,10 @@ route_1
- `name`: Joseph
- Requirements:
- `name`: [a-z]+
- Options:
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
- `opt1`: val1
- `opt2`: val2
route_2
@ -25,4 +29,8 @@ route_2
- Method: PUT|POST
- Class: Symfony\Component\Routing\Route
- Defaults: NONE
- Requirements: NONE
- Requirements: NO CUSTOM
- Options:
- `compiler_class`: Symfony\Component\Routing\RouteCompiler
- `opt1`: val1
- `opt2`: val2