-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[DependencyInjection] Document FQCN aliases #7656
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
|
||
Acme\TransformerInterface: | ||
alias: rot13_transformer | ||
public: false |
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.
why bother with public: false
? Let's show the short Acme\TransformerInterface: '@ rot13_transformer'
instead :)
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.
because we don't need this alias in the dumped container, it's better to show the best practices imo ;)
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.
I don't think we should bother with this kind of optimization that can lead to confusion here. And as it's not specific to autowiring, I should rather be in a dedicated section rather. The notion of public/private is a bit special in Symfony, I wouldn't mix it with autowiring.
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.
ok, let's remove it for now, we'll see if others think differently.
👍 just the |
autowiring_types: Acme\TransformerInterface | ||
class: Acme\Rot13Transformer | ||
|
||
Acme\TransformerInterface: @rot13_transformer |
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.
The @rot13_transformer
string needs to be quoted.
<service id="rot13_transformer" class="Acme\Rot13Transformer"> | ||
<autowiring-type>Acme\TransformerInterface</autowiring-type> | ||
</service> | ||
<service id="rot13_transformer" class="Acme\Rot13Transformer" /> |
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.
for consistency, we should add a blank line after this too
Fortunately, the FQCN alias is here to specify which implementation | ||
to use by default. | ||
|
||
.. versionadded:: 3.2 |
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.
3.3
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.
👍
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.
👍
99ba301
to
a544200
Compare
@GuilhemN could you please rebase this so we can merge it? Thanks! |
rebased ☺ |
@GuilhemN thanks for rebasing. This is now merged! |
This PR was merged into the master branch. Discussion ---------- [DependencyInjection] Document FQCN aliases Fix #7445 > Not only do we need to remove autowiring-types, we should show clearly how you can use aliases to choose what class should be autowired for a specific interface/class. > > Also, Stof noted that you can/should mark these aliases as private: we don't need them to be available on the final, cached container. Commits ------- a530019 [DependencyInjection] Document FQCN aliases
Fix #7445