Skip to content

Support for non-scalar tag attributes #38339

Closed
@aschempp

Description

@aschempp

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions