-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] container:debug : list services if no service match exacly the name argument #11339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
$helper = $this->getApplication()->getHelperSet()->get('question'); | ||
$question = new ChoiceQuestion( | ||
'Choose a number for more information on the service', | ||
$this->findServiceidsLike($builder, $name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be findServiceIdsLike
(capital I)
@@ -116,6 +118,10 @@ protected function execute(InputInterface $input, OutputInterface $output) | |||
$options['format'] = $input->getOption('format'); | |||
$options['raw_text'] = $input->getOption('raw'); | |||
$helper->describe($output, $object, $options); | |||
|
|||
if (!$input->getArgument('name') && $input->isInteractive()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the indentation of this block is wrong.
ce1acd3
to
7f866c3
Compare
return $name; | ||
} | ||
|
||
$helper = $this->getApplication()->getHelperSet()->get('question'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be $this->getHelper('question');
I like the approach! It's even easier than I was imagining because it doesn't make you re-run the command to find out more about the service you might be looking for. |
|
||
private function findProperServiceName(InputInterface $input, OutputInterface $output, ContainerBuilder $builder, $name) | ||
{ | ||
if ($builder->has($name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should also return early in case the input is not interactive (or you need to set $name
as the default in your Question)
7f866c3
to
22f7151
Compare
FYI - The PR has been updated after Stof's comment. |
$serviceIds = $builder->getServiceIds(); | ||
$foundServiceIds = array(); | ||
foreach ($serviceIds as $serviceId) { | ||
if (false === strpos($serviceId, $name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that service ids are always lowercase internally in Symfony, you should either use stripos
, or even better lowercase $name
(which can be done outside the loop)
… exacly the name argument | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#11303 | License | MIT | Doc PR | If we launch the command "container:debug log" and there is no service 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 informations are displayed.
22f7151
to
16201b6
Compare
I've updated the PR to lowercase the searched service name according to @stof comment |
Thank you @agallou. |
…o service match exacly the name argument (agallou) This PR was merged into the 2.6-dev branch. Discussion ---------- [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 no service 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 informations are displayed. Commits ------- 16201b6 [FrameworkBundle] container:debug : list services if no service match exacly the name argument
If we launch the command "container:debug log" and there is no
service nammed log, it will print something like this :
After the service has been chosen, usual container:debug informations
are displayed.