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

Commit16201b6

Browse files
committed
[FrameworkBundle] container:debug : list services if no service match exacly the name argument
| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#11303| License | MIT| Doc PR |If we launch the command "container:debug log" and there is noservice nammed log, it will print something like this :```[0] logger[1] monolog.handler.console[2] monolog.handler.debug```After the service has been chosen, usual container:debug informationsare displayed.
1 parent8b54211 commit16201b6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
useSymfony\Component\DependencyInjection\Loader\XmlFileLoader;
2020
useSymfony\Component\DependencyInjection\ContainerBuilder;
2121
useSymfony\Component\Config\FileLocator;
22+
useSymfony\Component\Console\Question\ChoiceQuestion;
2223

2324
/**
2425
* A console command for retrieving information about services.
@@ -106,6 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
106107
$options =array('tag' =>$tag,'show_private' =>$input->getOption('show-private'));
107108
}elseif ($name =$input->getArgument('name')) {
108109
$object =$this->getContainerBuilder();
110+
$name =$this->findProperServiceName($input,$output,$object,$name);
109111
$options =array('id' =>$name);
110112
}else {
111113
$object =$this->getContainerBuilder();
@@ -116,6 +118,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
116118
$options['format'] =$input->getOption('format');
117119
$options['raw_text'] =$input->getOption('raw');
118120
$helper->describe($output,$object,$options);
121+
122+
if (!$input->getArgument('name') &&$input->isInteractive()) {
123+
$output->writeln('To search for a service, re-run this command with a search term. <comment>container:debug log</comment>');
124+
}
119125
}
120126

121127
/**
@@ -168,4 +174,31 @@ protected function getContainerBuilder()
168174

169175
return$container;
170176
}
177+
178+
privatefunctionfindProperServiceName(InputInterface$input,OutputInterface$output,ContainerBuilder$builder,$name)
179+
{
180+
if ($builder->has($name) || !$input->isInteractive()) {
181+
return$name;
182+
}
183+
184+
$question =newChoiceQuestion('Choose a number for more information on the service',$this->findServiceIdsContaining($builder,$name));
185+
$question->setErrorMessage('Service %s is invalid.');
186+
187+
return$this->getHelper('question')->ask($input,$output,$question);
188+
}
189+
190+
privatefunctionfindServiceIdsContaining(ContainerBuilder$builder,$name)
191+
{
192+
$serviceIds =$builder->getServiceIds();
193+
$foundServiceIds =array();
194+
$name =strtolower($name);
195+
foreach ($serviceIdsas$serviceId) {
196+
if (false ===strpos($serviceId,$name)) {
197+
continue;
198+
}
199+
$foundServiceIds[] =$serviceId;
200+
}
201+
202+
return$foundServiceIds;
203+
}
171204
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp