feature #27551 [FrameworkBundle] show public/private for aliases in debug:container command (OskarStark)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[FrameworkBundle] show public/private for aliases in debug:container command

| Q             | A
| ------------- | ---
| Branch?       |  master
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |    <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | not needed <!-- required for new features -->

It could be helpful to see the public/private status for aliases in `debug:container` command.

Otherwise you need to dive into the code to get the information, because the result only shows the options of the aliased service.

## Look & Feel for public alias
![screenshot 2018-06-08 09 25 50](https://user-images.githubusercontent.com/995707/41144664-f3b50766-6afd-11e8-92d0-ca30513a1afc.png)

_text has slightly changed_

## Look & Feel for private alias
![screenshot 2018-06-08 09 23 31](https://user-images.githubusercontent.com/995707/41144593-b354aad2-6afd-11e8-8ab1-f9196e567f67.png)

_text has slightly changed_

//cc @nicolas-grekas

Commits
-------

1df7742345 [FrameworkBundle] show public/private for aliases in debug:container command
This commit is contained in:
Nicolas Grekas 2018-06-19 12:57:50 +02:00
commit c6948044c7
5 changed files with 9 additions and 5 deletions

View File

@ -352,7 +352,11 @@ class TextDescriptor extends Descriptor
*/
protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null)
{
$options['output']->comment(sprintf('This service is an alias for the service <info>%s</info>', (string) $alias));
if ($alias->isPublic()) {
$options['output']->comment(sprintf('This service is a <info>public</info> alias for the service <info>%s</info>', (string) $alias));
} else {
$options['output']->comment(sprintf('This service is a <comment>private</comment> alias for the service <info>%s</info>', (string) $alias));
}
if (!$builder) {
return;

View File

@ -1,3 +1,3 @@
 // This service is an alias for the service service_1
 // This service is a public alias for the service service_1

View File

@ -1,3 +1,3 @@
 // This service is an alias for the service .service_2
 // This service is a private alias for the service .service_2

View File

@ -1,4 +1,4 @@
 // This service is an alias for the service service_1
 // This service is a public alias for the service service_1
Information for Service "service_1"
===================================

View File

@ -1,4 +1,4 @@
 // This service is an alias for the service .service_2
 // This service is a private alias for the service .service_2
Information for Service ".service_2"
====================================