8000 Support for non-scalar tag attributes · Issue #38339 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Support for non-scalar tag attributes #38339

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

Closed
aschempp opened this issue Sep 29, 2020 · 2 comments · Fixed by #47364
Closed

Support for non-scalar tag attributes #38339

aschempp opened this issue Sep 29, 2020 · 2 comments · Fixed by #47364

Comments

@aschempp
Copy link
Contributor
aschempp commented Sep 29, 2020

Description
Currently, it is not possible to tag a service with an array of attributes. CheckDefinitionValidityPass prevents that. Is there a specific reason for that, especially to not support arrays of scalar values? If not, I'd be willing to provide a pull request 🙃

Example
In Contao CMS we're extensively using tags (and tags from annotations) to improve DX when adding new elements to the CMS. In our latest release, we're supporting dynamic routes (based on CMF-Routing) from controller services. It looks like this:

<?php

namespace App\Controller;

use Contao\CoreBundle\ServiceAnnotation\Page;

/**
 * @Page(path="foo/{id}", requirements={"id"="\d+"})
 */
class CustomPageController
{
}

This is automatically registered as a new Page Type, which CMS admins can place in their site structure. A page can be defined multiple times, either across domains or with a page alias (prefixed to the path).

Unfortunately, Symfony currently forbids array attributes in tags, which I don't understand why. I can work around this by simply removing the attributes in a compiler pass that runs before CheckDefinitionValidityPass (see contao/contao#2372), but that can't really be the solution? Also, we can't use YAML for the same because the YamlFileLoader checks for arrays as well.

@ro0NL
Copy link
Contributor
ro0NL commented Sep 30, 2020

I believe it's an XSD limitation currently, thus not supported by XML. I figure we could think of a nested structure, similar as argument collections.

leofeyer pushed a commit to contao/contao that referenced this issue Oct 6, 2020
Description
-----------

Fixes #2371

Let's see what symfony/symfony#38339 bringts up …

Commits
-------

7a35efc Remove existing tags from annotations that could  be arrays
de60bb6 Page type is optional, it's automatically generated in the compiler pass
leofeyer pushed a commit to contao/core-bundle that referenced this issue Oct 6, 2020
Description
-----------

Fixes contao/contao#2371

Let's see what symfony/symfony#38339 bringts up …

Commits
-------

7a35efc2 Remove existing tags from annotations that could  be arrays
de60bb6a Page type is optional, it's automatically generated in the compiler pass
@aschempp
Copy link
Contributor Author

Thanks for the hint @ro0NL, it took me a while to realize what you meant (because I never use XML). I've created a draft PR in #38540 to attempt a new feature 🙃. Should this issue be closed then?

AlexejKossmann pushed a commit to AlexejKossmann/contao that referenced this issue Apr 6, 2021
…o#2372)

Description
-----------

Fixes contao#2371

Let's see what symfony/symfony#38339 bringts up …

Commits
-------

7a35efc Remove existing tags from annotations that could  be arrays
de60bb6 Page type is optional, it's automatically generated in the compiler pass
fabpot added a commit that referenced this issue Oct 24, 2022
…ce tags (aschempp)

This PR was merged into the 6.2 branch.

Discussion
----------

[DependencyInjection] Allow array attributes for service tags

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #38339, #38540
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This adds array attribute support for container service tags as described in #38339. The most notable change is the additions to the XML schema for services, because that's the current limitation for not using array.

This is reopening #38540 as new PR since the other one was ("accidentially") closed 😊
/cc `@nicolas`-grekas

Commits
-------

edd8d77 [DependencyInjection] Allow array attributes for service tags
symfony-splitter pushed a commit to symfony/dependency-injection that referenced this issue Oct 24, 2022
…ce tags (aschempp)

This PR was merged into the 6.2 branch.

Discussion
----------

[DependencyInjection] Allow array attributes for service tags

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix symfony/symfony#38339, symfony/symfony#38540
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This adds array attribute support for container service tags as described in symfony/symfony#38339. The most notable change is the additions to the XML schema for services, because that's the current limitation for not using array.

This is reopening symfony/symfony#38540 as new PR since the other one was ("accidentially") closed 😊
/cc `@nicolas`-grekas

Commits
-------

edd8d776a0 [DependencyInjection] Allow array attributes for service tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
0