Skip to content

[RFC][DI] Get rid of tags #24432

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
Vinorcola opened this issue Oct 5, 2017 · 3 comments
Closed

[RFC][DI] Get rid of tags #24432

Vinorcola opened this issue Oct 5, 2017 · 3 comments

Comments

@Vinorcola
Copy link

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version ?

I was wondering, seing autoconfiguration system and the following pull requests:

if we could consider a futur without tags, tags simply being replaced by "instanceof".

Indeed, autoconfigure tends to add tags to classes implementing a certain type in order to inject them into another service. But rather than tagging according to implementations and then fetching tagged services, why do we not simply fetch services according to their implementation directly?

This would also bring more security has tagged services will have to implement a certain type (which you probably often want). And for those special cases where you want to tag different classes, you can just create an empty interface and make your services implement that empty interface.

WDYT?

@nicolas-grekas
Copy link
Member

Let's say some bundle has several EventSubscriberInterface, and a configuration in place to conditionally enable some of them for some reason, how would you do that? That's the purpose of tags: decouple interfaces and wiring. This is desired.

@stof
Copy link
Member

stof commented Oct 5, 2017

thus, we have many cases where tags need to provide additional metadata for the wiring (only half of the core tags are compatible with autoconfiguration due to that I would say).

So I don't see any benefit about removing tags entirely.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Oct 5, 2017

Closing as tags serve a unique and legitimate purpose. The nice thing as you spotted, is that you can already save yourself from using them for simple (yet common) use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants