Skip to content

Commit

Permalink
[FrameworkBundle] fixed missing information in some descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 7, 2015
1 parent b3a55fe commit 530af5c
Show file tree
Hide file tree
Showing 25 changed files with 175 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,15 @@ protected function getRouteData(Route $route)

return array(
'path' => $route->getPath(),
'pathRegex' => $route->compile()->getRegex(),
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '',
'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
'class' => get_class($route),
'defaults' => $route->getDefaults(),
'requirements' => $requirements ?: 'NO CUSTOM',
'options' => $route->getOptions(),
'pathRegex' => $route->compile()->getRegex(),
);
}

Expand All @@ -193,9 +194,24 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
'scope' => $definition->getScope(),
'public' => $definition->isPublic(),
'synthetic' => $definition->isSynthetic(),
'lazy' => $definition->isLazy(),
'synchronized' => $definition->isSynchronized(),
'abstract' => $definition->isSynchronized(),
'file' => $definition->getFile(),
);

if ($definition->getFactoryClass()) {
$data['factory_class'] = $definition->getFactoryClass();
}

if ($definition->getFactoryService()) {
$data['factory_service'] = $definition->getFactoryService();
}

if ($definition->getFactoryMethod()) {
$data['factory_method'] = $definition->getFactoryMethod();
}

if (!$omitTags) {
$data['tags'] = array();
if (count($definition->getTags())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ protected function describeRoute(Route $route, array $options = array())
unset($requirements['_scheme'], $requirements['_method']);

$output = '- Path: '.$route->getPath()
."\n".'- Path Regex: '.$route->compile()->getRegex()
."\n".'- Host: '.('' !== $route->getHost() ? $route->getHost() : 'ANY')
."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')
."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')
."\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".'- Options: '.$this->formatRouterConfig($route->getOptions())
."\n".'- Path-Regex: '.$route->compile()->getRegex();
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());

$this->write(isset($options['name'])
? $options['name']."\n".str_repeat('-', strlen($options['name']))."\n\n".$output
Expand Down Expand Up @@ -176,12 +177,27 @@ protected function describeContainerDefinition(Definition $definition, array $op
$output = '- Class: `'.$definition->getClass().'`'
."\n".'- Scope: `'.$definition->getScope().'`'
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no');
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
."\n".'- Synchronized: '.($definition->isSynchronized() ? 'yes' : 'no')
."\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no');

if ($definition->getFile()) {
$output .= "\n".'- File: `'.$definition->getFile().'`';
}

if ($definition->getFactoryClass()) {
$output .= "\n".'- Factory Class: `'.$definition->getFactoryClass().'`';
}

if ($definition->getFactoryService()) {
$output .= "\n".'- Factory Service: `'.$definition->getFactoryService().'`';
}

if ($definition->getFactoryMethod()) {
$output .= "\n".'- Factory Method: `'.$definition->getFactoryMethod().'`';
}

if (!(isset($options['omit_tags']) && $options['omit_tags'])) {
foreach ($definition->getTags() as $tagName => $tagData) {
foreach ($tagData as $parameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,22 @@ protected function describeRoute(Route $route, array $options = array())
// fixme: values were originally written as raw
$description = array(
'<comment>Path</comment> '.$route->getPath(),
'<comment>Path Regex</comment> '.$route->compile()->getRegex(),
'<comment>Host</comment> '.('' !== $route->getHost() ? $route->getHost() : 'ANY'),
'<comment>Host Regex</comment> '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : ''),
'<comment>Scheme</comment> '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'),
'<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>Options</comment> '.$this->formatRouterConfig($route->getOptions()),
'<comment>Path-Regex</comment> '.$route->compile()->getRegex(),
);

if (isset($options['name'])) {
array_unshift($description, '<comment>Name</comment> '.$options['name']);
array_unshift($description, $this->formatSection('router', sprintf('Route "%s"', $options['name'])));
}

if (null !== $route->compile()->getHostRegex()) {
$description[] = '<comment>Host-Regex</comment> '.$route->compile()->getHostRegex();
}

$this->writeText(implode("\n", $description)."\n", $options);
}

Expand Down Expand Up @@ -263,7 +260,25 @@ protected function describeContainerDefinition(Definition $definition, array $op
$description[] = sprintf('<comment>Scope</comment> %s', $definition->getScope());
$description[] = sprintf('<comment>Public</comment> %s', $definition->isPublic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
$description[] = sprintf('<comment>Lazy</comment> %s', $definition->isLazy() ? 'yes' : 'no');
$description[] = sprintf('<comment>Synchronized</comment> %s', $definition->isSynchronized() ? 'yes' : 'no');
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');

if ($definition->getFile()) {
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
}

if ($definition->getFactoryClass()) {
$description[] = sprintf('<comment>Factory Class</comment> %s', $definition->getFactoryClass());
}

if ($definition->getFactoryService()) {
$description[] = sprintf('<comment>Factory Service</comment> %s', $definition->getFactoryService());
}

if ($definition->getFactoryMethod()) {
$description[] = sprintf('<comment>Factory Method</comment> %s', $definition->getFactoryMethod());
}

$this->writeText(implode("\n", $description)."\n", $options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"scope": "container",
"public": true,
"synthetic": false,
"lazy": true,
"synchronized": true,
"abstract": true,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
"tags": [

]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ definition_1
- Scope: `container`
- Public: yes
- Synthetic: no
- Lazy: yes
- Synchronized: yes
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Aliases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"scope": "container",
"public": true,
"synthetic": false,
"lazy": true,
"synchronized": true,
"abstract": true,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
"tags": [

]
Expand All @@ -15,7 +20,12 @@
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
"tags": [
{
"name": "tag1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ definition_1
- Scope: `container`
- Public: yes
- Synthetic: no
- Lazy: yes
- Synchronized: yes
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
definition_2
~~~~~~~~~~~~
Expand All @@ -19,7 +24,12 @@ definition_2
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
- Tag: `tag1`
- Attr1: val1
- Attr2: val2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
"tags": [
{
"name": "tag1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ definition_2
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
- Tag: `tag1`
- Attr1: val1
- Attr2: val2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"scope": "container",
"public": false,
"synthetic": true,
"file": "\/path\/to\/file"
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get"
}
],
"tag2": [
Expand All @@ -14,7 +19,12 @@
"scope": "container",
"public": false,
"synthetic": true,
"file": "\/path\/to\/file"
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ definition_2
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
tag2
Expand All @@ -24,4 +29,9 @@ definition_2
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"scope": "container",
"public": true,
"synthetic": false,
"lazy": true,
"synchronized": true,
"abstract": true,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
"tags": [

]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
- Scope: `container`
- Public: yes
- Synthetic: no
- Lazy: yes
- Synchronized: yes
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<comment>Scope</comment> container
<comment>Public</comment> yes
<comment>Synthetic</comment> no
<comment>Required File</comment> -
<comment>Lazy</comment> yes
<comment>Synchronized</comment> yes
<comment>Abstract</comment> yes
<comment>Factory Class</comment> Full\Qualified\FactoryClass
<comment>Factory Method</comment> get
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"scope": "container",
"public": false,
"synthetic": true,
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
"tags": [
{
"name": "tag1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
- Scope: `container`
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
- Tag: `tag1`
- Attr1: val1
- Attr2: val2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
<comment>Scope</comment> container
<comment>Public</comment> no
<comment>Synthetic</comment> yes
<comment>Lazy</comment> no
<comment>Synchronized</comment> no
<comment>Abstract</comment> no
<comment>Required File</comment> /path/to/file
<comment>Factory Service</comment> factory.service
<comment>Factory Method</comment> get
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"path": "\/hello\/{name}",
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s",
"host": "localhost",
"hostRegex": "#^localhost$#s",
"scheme": "http|https",
"method": "GET|HEAD",
"class": "Symfony\\Component\\Routing\\Route",
Expand All @@ -14,6 +16,5 @@
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
"opt1": "val1",
"opt2": "val2"
},
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- Path: /hello/{name}
- Path Regex: #^/hello(?:/(?P<name>[a-z]+))?$#s
- Host: localhost
- Host Regex: #^localhost$#s
- Scheme: http|https
- Method: GET|HEAD
- Class: Symfony\Component\Routing\Route
Expand Down
Loading

0 comments on commit 530af5c

Please sign in to comment.