-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added a reference to private aliases #7384
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
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
$container->setDefinition('app.phpmailer', new Definition(PhpMailer::class)); | ||
|
||
$containerBuilder->setAlias('app.mailer', 'app.phpmailer'); | ||
|
||
// private aliases are created passing 'false' to Alias() second argument |
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.
[...] as the second argument
Aliases can be private by using other formats too, the same way as for classic services definitions: services:
app.mailer:
alias: app.phpmailer
public: false <service id="app.mailer" alias="app.phpmailer" public="false" /> |
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
$container->setDefinition('app.phpmailer', new Definition(PhpMailer::class)); | ||
|
||
$containerBuilder->setAlias('app.mailer', 'app.phpmailer'); | ||
|
||
// private aliases are created passing 'false' to Alias() second argument | ||
$containerBuilder->setAlias('app.mailer', new Alias('app.phpmailer', false)); | ||
|
||
This means that when using the container directly, you can access the |
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 this explanation, I wonder if the above place is the right place to show this? (the alias won't be usable using $container->get(...)
when private)
Can we please update this PR to add the other formats as well and include it at the end of the section instead? To avoid confusion as we're talking about "fetching it directly from the container" directly after it atm? |
I'm closing this because I don't know how to finish it. But I leave the related issue open in case somebody wants to fix it. Thanks! |
This fixes #5138.
If I'm right, you can only create private aliases with PHP code, so there's no need to update the other config formats.