8000 Don't show wanna-be-private services as public in debug:container · sroze/symfony@31f43e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31f43e5

Browse files
author
Robin Chalas
committed
Don't show wanna-be-private services as public in debug:container
1 parent 5f770d7 commit 31f43e5

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
113113
$service = $this->resolveServiceDefinition($builder, $serviceId);
114114

115115
if ($service instanceof Alias) {
116-
if ($showPrivate || $service->isPublic()) {
116+
if ($showPrivate || ($service->isPublic() && !$service->isPrivate())) {
117117
$data['aliases'][$serviceId] = $this->getContainerAliasData($service);
118118
}
119119
} elseif ($service instanceof Definition) {
120-
if (($showPrivate || $service->isPublic())) {
120+
if (($showPrivate || ($service->isPublic() && !$service->isPrivate()))) {
121121
$data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments);
122122
}
123123
} else {
@@ -217,7 +217,7 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
217217
{
218218
$data = array(
219219
'class' => (string) $definition->getClass(),
220-
'public' => $definition->isPublic(),
220+
'public' => $definition->isPublic() && !$definition->isPrivate(),
221221
'synthetic' => $definition->isSynthetic(),
222222
'lazy' => $definition->isLazy(),
223223
'shared' => $definition->isShared(),
@@ -281,7 +281,7 @@ private function getContainerAliasData(Alias $alias)
281281
{
282282
return array(
283283
'service' => (string) $alias,
284-
'public' => $alias->isPublic(),
284+
'public' => $alias->isPublic() && !$alias->isPrivate(),
285285
);
286286
}
287287

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
139139
$service = $this->resolveServiceDefinition($builder, $serviceId);
140140

141141
if ($service instanceof Alias) {
142-
if ($showPrivate || $service->isPublic()) {
142+
if ($showPrivate || ($service->isPublic() && !$service->isPrivate())) {
143143
$services['aliases'][$serviceId] = $service;
144144
}
145145
} elseif ($service instanceof Definition) {
146-
if (($showPrivate || $service->isPublic())) {
146+
if (($showPrivate || ($service->isPublic() && !$service->isPrivate()))) {
147147
$services['definitions'][$serviceId] = $service;
148148
}
149149
} else {
@@ -182,7 +182,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
182182
protected function describeContainerDefinition(Definition $definition, array $options = array())
183183
{
184184
$output = '- Class: `'.$definition->getClass().'`'
185-
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
185+
."\n".'- Public: '.($definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no')
186186
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
187187
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
188188
."\n".'- Shared: '.($definition->isShared() ? 'yes' : 'no')
@@ -246,7 +246,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
246246
protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null)
247247
{
248248
$output = '- Service: `'.$alias.'`'
249-
."\n".'- Public: '.($alias->isPublic() ? 'yes' : 'no');
249+
."\n".'- Public: '.($alias->isPublic() && !$alias->isPrivate() ? 'yes' : 'no');
250250

251251
if (!isset($options['id'])) {
252252
return $this->write($output);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
194194
$definition = $this->resolveServiceDefinition($builder, $serviceId);
195195
if ($definition instanceof Definition) {
196196
// filter out private services unless shown explicitly
197-
if (!$showPrivate && !$definition->isPublic()) {
197+
if (!$showPrivate && (!$definition->isPublic() || $definition->isPrivate())) {
198198
unset($serviceIds[$key]);
199199
continue;
200200
}
@@ -212,7 +212,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
212212
}
213213
}
214214
} elseif ($definition instanceof Alias) {
215-
if (!$showPrivate && !$definition->isPublic()) {
215+
if (!$showPrivate && (!$definition->isPublic() || $definition->isPrivate())) {
216216
unset($serviceIds[$key]);
217217
continue;
218218
}
@@ -302,7 +302,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
302302
$tableRows[] = array('Calls', implode(', ', $callInformation));
303303
}
304304

305-
$tableRows[] = array('Public', $definition->isPublic() ? 'yes' : 'no');
305+
$tableRows[] = array('Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no');
306306
$tableRows[] = array('Synthetic', $definition->isSynthetic() ? 'yes' : 'no');
307307
$tableRows[] = array('Lazy', $definition->isLazy() ? 'yes' : 'no');
308308
$tableRows[] = array('Shared', $definition->isShared() ? 'yes' : 'no');

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private function getContainerServicesDocument(ContainerBuilder $builder, $tag =
318318
foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
319319
$service = $this->resolveServiceDefinition($builder, $serviceId);
320320

321-
if (($service instanceof Definition || $service instanceof Alias) && !($showPrivate || $service->isPublic())) {
321+
if (($service instanceof Definition || $service instanceof Alias) && !($showPrivate || ($service->isPublic() && !$service->isPrivate()))) {
322322
continue;
323323
}
324324

@@ -364,7 +364,7 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu
364364
}
365365
}
366366

367-
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
367+
$serviceXML->setAttribute('public', $definition->isPublic() && !$definition->isPrivate() ? 'true' : 'false');
368368
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
369369
$serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false');
370370
$serviceXML->setAttribute('shared', $definition->isShared() ? 'true' : 'false');
@@ -469,7 +469,7 @@ private function getContainerAliasDocument(Alias $alias, $id = null)
469469
}
470470

471471
$aliasXML->setAttribute('service', (string) $alias);
472-
$aliasXML->setAttribute('public', $alias->isPublic() ? 'true' : 'false');
472+
$aliasXML->setAttribute('public', $alias->isPublic() && !$alias->isPrivate() ? 'true' : 'false');
473473

474474
return $dom;
475475
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"%parameter%",
1818
{
1919
"class": "inline_service",
20-
"public": true,
20+
"public": false,
2121
"synthetic": false,
2222
"lazy": false,
2323
"shared": true,
@@ -39,7 +39,7 @@
3939
},
4040
{
4141
"class": "inline_service",
42-
"public": true,
42+
"public": false,
4343
"synthetic": false,
4444
"lazy": false,
4545
"shared": true,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<argument type="service" id="definition2"/>
77
<argument>%parameter%</argument>
88
<argument>
9-
<definition class="inline_service" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
9+
<definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
1010
<argument>arg1</argument>
1111
<argument>arg2</argument>
1212
</definition>
@@ -15,7 +15,7 @@
1515
<argument>foo</argument>
1616
<argument type="service" id="definition2"/>
1717
<argument>
18-
<definition class="inline_service" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
18+
<definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
1919
</argument>
2020
</argument>
2121
<argument type="iterator">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"%parameter%",
1616
{
1717
"class": "inline_service",
18-
"public": true,
18+
"public": false,
1919
"synthetic": false,
2020
"lazy": false,
2121
"shared": true,
@@ -37,7 +37,7 @@
3737
},
3838
{
3939
"class": "inline_service",
40-
"public": true,
40+
"public": false,
4141
"synthetic": false,
4242
"lazy": false,
4343
"shared": true,

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<argument type="service" id="definition2"/>
55
<argument>%parameter%</argument>
66
<argument>
7-
<definition class="inline_service" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
7+
<definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
88
<argument>arg1</argument>
99
<argument>arg2</argument>
1010
</definition>
@@ -13,7 +13,7 @@
1313
<argument>foo</argument>
1414
<argument type="service" id="definition2"/>
1515
<argument>
16-
<definition class="inline_service" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
16+
<definition class="inline_service" public="false" synthe 4B78 tic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
1717
</argument>
1818
</argument>
1919
<argument type="iterator">

0 commit comments

Comments
 (0)
0