Skip to content

[DI] allow loading and dumping tags with an attribute named "name" #36586

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

Merged
merged 1 commit into from
May 3, 2020

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

This is a minor feature added for consistency: using PHP, we can already define tags with an attribute named "name". But then, we cannot dump such definitions in YAML nor XML since we don't have a syntax to declare such tags in these formats.

I spotted this while looking at a dumped container: we already use an attribute named "name" on two tags: cache.pool and workflow.definition. Currently, the dumped XML is wrong because of this.

This PR enables the following new syntaxes (the current style still works as usual):

  • in YAML, consistently with the new syntax for method calls:
    tags:
      - cache.pool: { name: my_cache_pool }
  • in XML:
    <tag name="my_cache_pool">cache.pool</tag>

@fabpot
Copy link
Member

fabpot commented May 3, 2020

Thank you @nicolas-grekas.

@fabpot fabpot merged commit d6aa205 into symfony:master May 3, 2020
@nicolas-grekas nicolas-grekas deleted the di-name-tag-attr branch May 4, 2020 08:04
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
nicolas-grekas added a commit that referenced this pull request Apr 21, 2023
…when it does not define their name (MatTheCat)

This PR was squashed before being merged into the 6.2 branch.

Discussion
----------

[DependencyInjection] Do not ignore tags `name` attribute when it does not define their name

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #50081
| License       | MIT
| Doc PR        | N/A

Tags `name` attribute is ignored using XML if the tag name is its node content. That means `<tag name="name_attribute">tag_name</tag>` will return a `tag_name` tag without any attribute.

This seems to be a regression from #36586.

Commits
-------

4c9c688 [DependencyInjection] Do not ignore tags `name` attribute when it does not define their name
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.

3 participants