Skip to content
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

[FrameworkBundle] container:debug : list services if no service match exacly the name argument #11339

Merged
merged 1 commit into from Oct 2, 2014

Conversation

agallou
Copy link
Contributor

@agallou agallou commented Jul 6, 2014

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.

$helper = $this->getApplication()->getHelperSet()->get('question');
$question = new ChoiceQuestion(
'Choose a number for more information on the service',
$this->findServiceidsLike($builder, $name)

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()) {
Copy link
Member

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.

@agallou agallou force-pushed the container_debug_search_services branch from ce1acd3 to 7f866c3 Compare September 7, 2014 17:49
return $name;
}

$helper = $this->getApplication()->getHelperSet()->get('question');
Copy link
Member

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');

@weaverryan
Copy link
Member

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)) {
Copy link
Member

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)

@agallou agallou force-pushed the container_debug_search_services branch from 7f866c3 to 22f7151 Compare September 25, 2014 21:50
@weaverryan
Copy link
Member

FYI - The PR has been updated after Stof's comment.

$serviceIds = $builder->getServiceIds();
$foundServiceIds = array();
foreach ($serviceIds as $serviceId) {
if (false === strpos($serviceId, $name)) {
Copy link
Member

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.
@agallou agallou force-pushed the container_debug_search_services branch from 22f7151 to 16201b6 Compare October 2, 2014 06:19
@agallou
Copy link
Contributor Author

agallou commented Oct 2, 2014

I've updated the PR to lowercase the searched service name according to @stof comment

@fabpot
Copy link
Member

fabpot commented Oct 2, 2014

Thank you @agallou.

@fabpot fabpot merged commit 16201b6 into symfony:master Oct 2, 2014
fabpot added a commit that referenced this pull request Oct 2, 2014
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants