Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Why does switching from annotation to attribute disables tagging and service creation for entities#61124

Unanswered
s-bernstein asked this question inQ&A
Discussion options

I'm in the process of updating a product to Symfony 6.4 from Symfony 5.4. Now I have a rather curious behaviour that I can't explain.

This product uses some tagged iterators to collect declared classes. Some of theses classes are doctrine entities. All of this works fine in 5.4 and 6.4, if I'm using annotations to mark the entity@ORM\Entity. The class is tagged and the tagged iterator works as expected. Also, automatically or manually declared services will work.

The moment I switch to attribute#[ORM\Entity] none of this works any more. Services are not created, the class is not tagged and ultimately it is missing in the tagged iterator. I also tried to useAutoconfigureTag attribute to no avail. And it is only theEntity attribute. I can use all other attributes in the entity and just set theEntity via annotation and it works as expected.

Am I doing something wrong? Is this behaviour intended? I couldn't find any documentation for this.

You must be logged in to vote

Replies: 1 comment 7 replies

Comment options

Doctrine entities have been excluded from the container by#59987 (amongst others) because they are not services.

What is your use-case?

You must be logged in to vote
7 replies
@s-bernstein
Comment options

Makes no difference, because then I would need a list of these persisted configuration objects...

@MatTheCat
Comment options

I thought placeholders would be able to fetch their own configuration 🤷

@s-bernstein
Comment options

It's not the fetching, that's the problem. To create a new placeholder of a certain type, I need an admin class for SonataAdmin and that will need a referenced entity class. To get a selection of possible placeholders on the admin backend to create a new entry, I need a list with these entities (and there admin class, but that's not important right now).

Also, this is not our only bundle that is affected.

@stof
Comment options

stofJul 16, 2025
Collaborator

this looks like a use case forContainerBuilder::findTaggedResourceIds that exists in Symfony 7.3, if the goal is to identify things that are meant to be excluded as services.

@s-bernstein
Comment options

OK, that's fine for Symfony 7.3, but that doesn't help in Symfony 6.4, where this feature doesn't exists. Will this be backported? Because without it, the changes to doctrine-bundle to exclude Entities are without a resolution, as far as I understand it.

Also, is the CompilerPass the only way to get the list, or do the tagged iterators work on resource tags?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
3 participants
@s-bernstein@stof@MatTheCat

[8]ページ先頭

©2009-2025 Movatter.jp