Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4ac1a4

Browse files
committed
[FrameworkBundle] Add service deprecation on debug:container command output
1 parent18809d8 commitf4ac1a4

File tree

67 files changed

+134
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+134
-30
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,21 @@ protected function sortByPriority(array $tag): array
286286
return$tag;
287287
}
288288

289+
protectedfunctiongetDefinitionDeprecationMessage(Definition$definition,string$serviceId =null):string
290+
{
291+
$deprecationMessage ='';
292+
293+
if (null !==$serviceId) {
294+
$deprecationMessage =$definition->getDeprecation($serviceId)['message'] ??'';
295+
}
296+
297+
if (empty($deprecationMessage)) {
298+
$deprecationMessage =$definition->getClass() .' is deprecated.';
299+
}
300+
301+
return$deprecationMessage;
302+
}
303+
289304
publicstaticfunctiongetClassDescription(string$class,string &$resolvedClass =null):string
290305
{
291306
$resolvedClass =$class;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ private function getContainerDefinitionData(Definition $definition, bool $omitTa
230230
'autoconfigure' =>$definition->isAutoconfigured(),
231231
];
232232

233+
if ($definition->isDeprecated()) {
234+
$data['deprecated'] ='yes -' .$this->getDefinitionDeprecationMessage($definition,null);
235+
}else {
236+
$data['deprecated'] ='no';
237+
}
238+
233239
if ('' !==$classDescription =$this->getClassDescription((string)$definition->getClass())) {
234240
$data['description'] =$classDescription;
235241
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ protected function describeContainerDefinition(Definition $definition, array $op
211211
."\n".'- Autoconfigured:'.($definition->isAutoconfigured() ?'yes' :'no')
212212
;
213213

214+
if ($definition->isDeprecated()) {
215+
$output .="\n".'- Deprecated: yes' .$this->getDefinitionDeprecationMessage($definition,$options['id']);
216+
}else {
217+
$output .="\n".'- Deprecated: no';
218+
}
219+
214220
if (isset($options['show_arguments']) &&$options['show_arguments']) {
215221
$output .="\n".'- Arguments:'.($definition->getArguments() ?'yes' :'no');
216222
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ protected function describeContainerDefinition(Definition $definition, array $op
263263

264264
$tableHeaders = ['Option','Value'];
265265

266-
$tableRows[] = ['Service ID',$options['id'] ??'-'];
266+
$serviceId =$options['id'];
267+
$tableRows[] = ['Service ID',$serviceId ??'-'];
267268
$tableRows[] = ['Class',$definition->getClass() ?:'-'];
268269

269270
$omitTags =isset($options['omit_tags']) &&$options['omit_tags'];
@@ -306,6 +307,12 @@ protected function describeContainerDefinition(Definition $definition, array $op
306307
$tableRows[] = ['Autowired',$definition->isAutowired() ?'yes' :'no'];
307308
$tableRows[] = ['Autoconfigured',$definition->isAutoconfigured() ?'yes' :'no'];
308309

310+
if ($definition->isDeprecated()) {
311+
$tableRows[] = ['Deprecated','<comment>yes -' .$this->getDefinitionDeprecationMessage($definition,$serviceId) .'</comment>'];
312+
}else {
313+
$tableRows[] = ['Deprecated','no'];
314+
}
315+
309316
if ($definition->getFile()) {
310317
$tableRows[] = ['Required File',$definition->getFile() ?:'-'];
311318
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ private function getContainerDefinitionDocument(Definition $definition, string $
341341
$serviceXML->setAttribute('abstract',$definition->isAbstract() ?'true' :'false');
342342
$serviceXML->setAttribute('autowired',$definition->isAutowired() ?'true' :'false');
343343
$serviceXML->setAttribute('autoconfigured',$definition->isAutoconfigured() ?'true' :'false');
344+
if ($definition->isDeprecated()) {
345+
$serviceXML->setAttribute('deprecated','true' .$this->getDefinitionDeprecationMessage($definition,$id));
346+
}else {
347+
$serviceXML->setAttribute('deprecated','false');
348+
}
344349
$serviceXML->setAttribute('file',$definition->getFile() ??'');
345350

346351
$calls =$definition->getMethodCalls();

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"abstract":true,
1313
"autowire":false,
1414
"autoconfigure":false,
15+
"deprecated":false,
1516
"file":null,
1617
"factory_class":"Full\\Qualified\\FactoryClass",
1718
"factory_method":"get",

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
- Abstract: yes
1414
- Autowired: no
1515
- Autoconfigured: no
16+
- Deprecated: no
1617
- Factory Class:`Full\Qualified\FactoryClass`
1718
- Factory Method:`get`

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Abstract yes
1717
Autowired no
1818
Autoconfigured no
19+
Deprecated no
1920
Factory Class Full\Qualified\FactoryClass
2021
Factory Method get
2122
---------------- -----------------------------
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<aliasid="alias_1"service="service_1"public="true"/>
3-
<definitionid="service_1"class="Full\Qualified\Class1"public="true"synthetic="false"lazy="true"shared="true"abstract="true"autowired="false"autoconfigured="false"file="">
3+
<definitionid="service_1"class="Full\Qualified\Class1"public="true"synthetic="false"lazy="true"shared="true"abstract="true"autowired="false"autoconfigured="false"deprecated="false"file="">
44
<factoryclass="Full\Qualified\FactoryClass"method="get"/>
55
</definition>

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"abstract":false,
1313
"autowire":false,
1414
"autoconfigure":false,
15+
"deprecated":false,
1516
"file":"\/path\/to\/file",
1617
"factory_service":"factory.service",
1718
"factory_method":"get",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp