Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36e5480

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: added missing support for factories in console descriptions [FrameworkBundle] fixed missing information in some descriptors Conflicts: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt
2 parents 0577065 + 8d982f8 commit 36e5480

25 files changed

+224
-28
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
2020
use Symfony\Component\DependencyInjection\Definition;
2121
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
22+
use Symfony\Component\DependencyInjection\Reference;
2223
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2324
use Symfony\Component\Routing\Route;
2425
use Symfony\Component\Routing\RouteCollection;
@@ -188,14 +189,15 @@ protected function getRouteData(Route $route)
188189

189190
return array(
190191
'path' => $route->getPath(),
192+
'pathRegex' => $route->compile()->getRegex(),
191193
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
194+
'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '',
192195
'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
193196
'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
194197
'class' => get_class($route),
195198
'defaults' => $route->getDefaults(),
196199
'requirements' => $requirements ?: 'NO CUSTOM',
197200
'options' => $route->getOptions(),
198-
'pathRegex' => $route->compile()->getRegex(),
199201
);
200202
}
201203

@@ -212,9 +214,39 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
212214
'scope' => $definition->getScope(),
213215
'public' => $definition->isPublic(),
214216
'synthetic' => $definition->isSynthetic(),
217+
'lazy' => $definition->isLazy(),
218+
'synchronized' => $definition->isSynchronized(),
219+
'abstract' => $definition->isSynchronized(),
215220
'file' => $definition->getFile(),
216221
);
217222

223+
if ($definition->getFactoryClass()) {
224+
$data['factory_class'] = $definition->getFactoryClass();
225+
}
226+
227+
if ($definition->getFactoryService()) {
228+
$data['factory_service'] = $definition->getFactoryService();
229+
}
230+
231+
if ($definition->getFactoryMethod()) {
232+
$data['factory_method'] = $definition->getFactoryMethod();
233+
}
234+
235+
if ($factory = $definition->getFactory()) {
236+
if (is_array($factory)) {
237+
if ($factory[0] instanceof Reference) {
238+
$data['factory_service'] = (string) $factory[0];
239+
} elseif ($factory[0] instanceof Definition) {
240+
throw new \InvalidArgumentException('Factory is not describable.');
241+
} else {
242+
$data['factory_class'] = $factory[0];
243+
}
244+
$data['factory_method'] = $factory[1];
245+
} else {
246+
$data['factory_function'] = $factory;
247+
}
248+
}
249+
218250
if (!$omitTags) {
219251
$data['tags'] = array();
220252
if (count($definition->getTags())) {

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
18+
use Symfony\Component\DependencyInjection\Reference;
1819
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1920
use Symfony\Component\Routing\Route;
2021
use Symfony\Component\Routing\RouteCollection;
@@ -52,14 +53,15 @@ protected function describeRoute(Route $route, array $options = array())
5253
unset($requirements['_scheme'], $requirements['_method']);
5354

5455
$output = '- Path: '.$route->getPath()
56+
."\n".'- Path Regex: '.$route->compile()->getRegex()
5557
."\n".'- Host: '.('' !== $route->getHost() ? $route->getHost() : 'ANY')
58+
."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')
5659
."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')
5760
."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')
5861
."\n".'- Class: '.get_class($route)
5962
."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults())
6063
."\n".'- Requirements: '.$this->formatRouterConfig($requirements) ?: 'NONE'
61-
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions())
62-
."\n".'- Path-Regex: '.$route->compile()->getRegex();
64+
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
6365

6466
$this->write(isset($options['name'])
6567
? $options['name']."\n".str_repeat('-', strlen($options['name']))."\n\n".$output
@@ -179,12 +181,42 @@ protected function describeContainerDefinition(Definition $definition, array $op
179181
$output = '- Class: `'.$definition->getClass().'`'
180182
."\n".'- Scope: `'.$definition->getScope().'`'
181183
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
182-
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no');
184+
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
185+
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
186+
."\n".'- Synchronized: '.($definition->isSynchronized() ? 'yes' : 'no')
187+
."\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no');
183188

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

193+
if ($definition->getFactoryClass()) {
194+
$output .= "\n".'- Factory Class: `'.$definition->getFactoryClass().'`';
195+
}
196+
197+
if ($definition->getFactoryService()) {
198+
$output .= "\n".'- Factory Service: `'.$definition->getFactoryService().'`';
199+
}
200+
201+
if ($definition->getFactoryMethod()) {
202+
$output .= "\n".'- Factory Method: `'.$definition->getFactoryMethod().'`';
203+
}
204+
205+
if ($factory = $definition->getFactory()) {
206+
if (is_array($factory)) {
207+
if ($factory[0] instanceof Reference) {
208+
$output .= "\n".'- Factory Service: `'.$factory[0].'`';
209+
} elseif ($factory[0] instanceof Definition) {
210+
throw new \InvalidArgumentException('Factory is not describable.');
211+
} else {
212+
$output .= "\n".'- Factory Class: `'.$factory[0].'`';
213+
}
214+
$output .= "\n".'- Factory Method: `'.$factory[1].'`';
215+
} else {
216+
$output .= "\n".'- Factory Function: `'.$factory.'`';
217+
}
218+
}
219+
188220
if (!(isset($options['omit_tags']) && $options['omit_tags'])) {
189221
foreach ($definition->getTags() as $tagName => $tagData) {
190222
foreach ($tagData as $parameters) {

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Definition;
1818
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
19+
use Symfony\Component\DependencyInjection\Reference;
1920
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2021
use Symfony\Component\Routing\Route;
2122
use Symfony\Component\Routing\RouteCollection;
@@ -75,25 +76,22 @@ protected function describeRoute(Route $route, array $options = array())
7576
// fixme: values were originally written as raw
7677
$description = array(
7778
'<comment>Path</comment> '.$route->getPath(),
79+
'<comment>Path Regex</comment> '.$route->compile()->getRegex(),
7880
'<comment>Host</comment> '.('' !== $route->getHost() ? $route->getHost() : 'ANY'),
81+
'<comment>Host Regex</comment> '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : ''),
7982
'<comment>Scheme</comment> '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'),
8083
'<comment>Method</comment> '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'),
8184
'<comment>Class</comment> '.get_class($route),
8285
'<comment>Defaults</comment> '.$this->formatRouterConfig($route->getDefaults()),
8386
'<comment>Requirements</comment> '.$this->formatRouterConfig($requirements) ?: 'NO CUSTOM',
8487
'<comment>Options</comment> '.$this->formatRouterConfig($route->getOptions()),
85-
'<comment>Path-Regex</comment> '.$route->compile()->getRegex(),
8688
);
8789

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

93-
if (null !== $route->compile()->getHostRegex()) {
94-
$description[] = '<comment>Host-Regex</comment> '.$route->compile()->getHostRegex();
95-
}
96-
9795
$this->writeText(implode("\n", $description)."\n", $options);
9896
}
9997

@@ -266,7 +264,40 @@ protected function describeContainerDefinition(Definition $definition, array $op
266264
$description[] = sprintf('<comment>Scope</comment> %s', $definition->getScope());
267265
$description[] = sprintf('<comment>Public</comment> %s', $definition->isPublic() ? 'yes' : 'no');
268266
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
269-
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
267+
$description[] = sprintf('<comment>Lazy</comment> %s', $definition->isLazy() ? 'yes' : 'no');
268+
$description[] = sprintf('<comment>Synchronized</comment> %s', $definition->isSynchronized() ? 'yes' : 'no');
269+
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');
270+
271+
if ($definition->getFile()) {
272+
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
273+
}
274+
275+
if ($definition->getFactoryClass()) {
276+
$description[] = sprintf('<comment>Factory Class</comment> %s', $definition->getFactoryClass());
277+
}
278+
279+
if ($definition->getFactoryService()) {
280+
$description[] = sprintf('<comment>Factory Service</comment> %s', $definition->getFactoryService());
281+
}
282+
283+
if ($definition->getFactoryMethod()) {
284+
$description[] = sprintf('<comment>Factory Method</comment> %s', $definition->getFactoryMethod());
285+
}
286+
287+
if ($factory = $definition->getFactory()) {
288+
if (is_array($factory)) {
289+
if ($factory[0] instanceof Reference) {
290+
$description[] = sprintf('<comment>Factory Service</comment> %s', $factory[0]);
291+
} elseif ($factory[0] instanceof Definition) {
292+
throw new \InvalidArgumentException('Factory is not describable.');
293+
} else {
294+
$description[] = sprintf('<comment>Factory Class</comment> %s', $factory[0]);
295+
}
296+
$description[] = sprintf('<comment>Factory Method</comment> %s', $factory[1]);
297+
} else {
298+
$description[] = sprintf('<comment>Factory Function</comment> %s', $factory);
299+
}
300+
}
270301

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

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"scope": "container",
66
"public": true,
77
"synthetic": false,
8+
"lazy": true,
9+
"synchronized": true,
10+
"abstract": true,
811
"file": null,
12+
"factory_class": "Full\\Qualified\\FactoryClass",
13+
"factory_method": "get",
914
"tags": [
1015

1116
]

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ definition_1
1111
- Scope: `container`
1212
- Public: yes
1313
- Synthetic: no
14+
- Lazy: yes
15+
- Synchronized: yes
16+
- Abstract: yes
17+
- Factory Class: `Full\Qualified\FactoryClass`
18+
- Factory Method: `get`
1419
1520
1621
Aliases

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"scope": "container",
66
"public": true,
77
"synthetic": false,
8+
"lazy": true,
9+
"synchronized": true,
10+
"abstract": true,
811
"file": null,
12+
"factory_class": "Full\\Qualified\\FactoryClass",
13+
"factory_method": "get",
914
"tags": [
1015

1116
]
@@ -15,7 +20,12 @@
1520
"scope": "container",
1621
"public": false,
1722
"synthetic": true,
23+
"lazy": false,
24+
"synchronized": false,
25+
"abstract": false,
1826
"file": "\/path\/to\/file",
27+
"factory_service": "factory.service",
28+
"factory_method": "get",
1929
"tags": [
2030
{
2131
"name": "tag1",

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ definition_1
1111
- Scope: `container`
1212
- Public: yes
1313
- Synthetic: no
14+
- Lazy: yes
15+
- Synchronized: yes
16+
- Abstract: yes
17+
- Factory Class: `Full\Qualified\FactoryClass`
18+
- Factory Method: `get`
1419
1520
definition_2
1621
~~~~~~~~~~~~
@@ -19,7 +24,12 @@ definition_2
1924
- Scope: `container`
2025
- Public: no
2126
- Synthetic: yes
27+
- Lazy: no
28+
- Synchronized: no
29+
- Abstract: no
2230
- File: `/path/to/file`
31+
- Factory Service: `factory.service`
32+
- Factory Method: `get`
2333
- Tag: `tag1`
2434
- Attr1: val1
2535
- Attr2: val2

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"scope": "container",
66
"public": false,
77
"synthetic": true,
8+
"lazy": false,
9+
"synchronized": false,
10+
"abstract": false,
811
"file": "\/path\/to\/file",
12+
"factory_service": "factory.service",
13+
"factory_method": "get",
914
"tags": [
1015
{
1116
"name": "tag1",

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ definition_2
1111
- Scope: `container`
1212
- Public: no
1313
- Synthetic: yes
14+
- Lazy: no
15+
- Synchronized: no
16+
- Abstract: no
1417
- File: `/path/to/file`
18+
- Factory Service: `factory.service`
19+
- Factory Method: `get`
1520
- Tag: `tag1`
1621
- Attr1: val1
1722
- Attr2: val2

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"scope": "container",
66
"public": false,
77
"synthetic": true,
8-
"file": "\/path\/to\/file"
8+
"lazy": false,
9+
"synchronized": false,
10+
"abstract": false,
11+
"file": "\/path\/to\/file",
12+
"factory_service": "factory.service",
13+
"factory_method": "get"
914
}
1015
],
1116
"tag2": [
@@ -14,7 +19,12 @@
1419
"scope": "container",
1520
"public": false,
1621
"synthetic": true,
17-
"file": "\/path\/to\/file"
22+
"lazy": false,
23+
"synchronized": false,
24+
"abstract": false,
25+
"file": "\/path\/to\/file",
26+
"factory_service": "factory.service",
27+
"factory_method": "get"
1828
}
1929
]
2030
}

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ definition_2
1111
- Scope: `container`
1212
- Public: no
1313
- Synthetic: yes
14+
- Lazy: no
15+
- Synchronized: no
16+
- Abstract: no
1417
- File: `/path/to/file`
18+
- Factory Service: `factory.service`
19+
- Factory Method: `get`
1520
1621
1722
tag2
@@ -24,4 +29,9 @@ definition_2
2429
- Scope: `container`
2530
- Public: no
2631
- Synthetic: yes
32+
- Lazy: no
33+
- Synchronized: no
34+
- Abstract: no
2735
- File: `/path/to/file`
36+
- Factory Service: `factory.service`
37+
- Factory Method: `get`

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
"scope": "container",
44
"public": true,
55
"synthetic": false,
6+
"lazy": true,
7+
"synchronized": true,
8+
"abstract": true,
69
"file": null,
10+
"factory_class": "Full\\Qualified\\FactoryClass",
11+
"factory_method": "get",
712
"tags": [
813

914
]
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
- Class: `Full\Qualified\Class1`
22
- Scope: `container`
33
- Public: yes
4-
- Synthetic: no
4+
- Synthetic: no
5+
- Lazy: yes
6+
- Synchronized: yes
7+
- Abstract: yes
8+
- Factory Class: `Full\Qualified\FactoryClass`
9+
- Factory Method: `get`

0 commit comments

Comments
 (0)