Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
[DependencyInjection] Allow loading and dumping tags with an attribute named "name"#18802
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ec62391
to52aee81
Compare@@ -515,6 +515,45 @@ To answer this, change the service declaration: | |||
; | |||
}; | |||
.. tip:: | |||
In XML and YAML format, you may provide the tag an attribute called ``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.
I don't understand this "feature".
- Is the
name
attribute special here? - If it's special: what does that imply?
- If it's not special: why mention this at all? If it's just like any other attribute, why mention this
name
attribute in particular?
Thanks!
alexandre-dauboisAug 31, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Thename
attribute is not special itself. Actually, this tip indicates that you can use an attribute namedname
, which wasn't possible before 5.1. Also, this shows that if you need to add aname
attribute on a tag, youmust use a "special" syntax. Otherwise, thename
attribute will be interpreted asthe tag name, not as an attribute of it.
By doing
MailerSendmailTransport:tags: -{ name: 'app.mail_transport', alias: 'sendmail' }
You declare a tag with theapp.mail_transport
nameand an attribute calledalias
. This is a bit misleading becausealias
andname
keys are at the same level. If you actually need an attribute calledname
, you must do the following:
MailerSmtpTransport:arguments:['%mailer_host%']tags: -app.mail_transport:{ name: 'arbitrary-value', alias: 'smtp' }
It took me some time to fully understand what this PR was all about 😄
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.
By default, thename
XML attribute contains the tag name, and so cannot be used to set an attribute namedname
. As of 5.1, there is a way to usename
as an attribute by passing the tag name in the body of the XML element 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.
Thanks for your explanation. Now I can fully understand what's happening here. So, I've done some tweaks while merging to hopefully make it less confusing to readers:6e6565b
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.
Perfect! 🙂
Alex, thanks a lot for contributing this ... and congrats on completing theSymfony 5.1 milestone 🎉 |
Uh oh!
There was an error while loading.Please reload this page.
Not an easy one to fully understand. Friendly ping@stof as you participated to the issue 🙂 Thanks!
Fix#13613