doctrine / mongodb-odm

The Official PHP MongoDB ORM/ODM
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
MIT License
1.09k stars 504 forks source link

What is the purpose of the undocumented "DiscriminatorValue" annotation ? #644

Open NoiseByNorthwest opened 11 years ago

jmikola commented 11 years ago

It chains to ClassMetadataInfo::setDiscriminatorValue(), which appears to set the current class in the map with the given value as its key.

I don't have any information beyond that, but I was able to trace it to @jwage's original commit in https://github.com/doctrine/mongodb-odm/commit/4cdacfb64f339ae286c6aab078c160422f693781.

NoiseByNorthwest commented 11 years ago

Ok, I understand. Unfortunately there is no hydration mechanism for resolving discriminatormap from subclasses' discriminatorvalue, and it would be a really great feature.

jwage commented 11 years ago

That was my original intent, but I never got around to hooking it all up. I think we need something that will build all the discriminator values from child classes and store it in the metadata.

vmattila commented 10 years ago

Well, this seems a very interesting feature. I have an inheritance structure that has currently approximately ~50 different subclasses and the annotation in the superclass is getting ugly.

It would be excellent if this would work also with @EmbedMany / @EmbedOne inheritance. Currently if we are using a certain embedded document classes in multiple documents, each of the main document needs to duplicate the @DiscriminatorMap value in the field definition. This @DiscriminatorValue would most propably work there well.

alcaeus commented 6 years ago

Closing: this has long been implemented and working.

malarzm commented 6 years ago

It is still undocumebted tho, reopening and retriaging

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

alcaeus commented 5 years ago

Bad bot...