Allow ORM to use ResolveTargetEntityListener
in ManagerRegistry::getManagerForClass()
#149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am not quite sure if this is the right place to ask, because the change aims at a feature of ORM. Anyways, here it goes:
Doctrine ORM features a ResolveTargetEntityListener. This mechanism allows to use Interface names in various places, for example in Association Mappings or when querying Repositories from Entity Managers.
It would be helpful if the
AbstractManagerRegistry
could support looking up Managers by such interfaces as well.The problem with the current implementation is that it makes use of the
isTransient
property. Probably this happens to speed up things: Inside the Metadata Factory, the Driver can determineisTransient()
more easily, without loading the full metadata.Interfaces, however, are (to my understanding) always transient, so
getManagerForClass()
never works for them. This is where this PR hopes to improve things without affecting performance for existing use cases.Will add tests once I get basic approval and 👍s.
Background:
ManagerRegistry::getManagerForClass()
is used inside https://github.com/sensiolabs/SensioFrameworkExtraBundle for the Symfony Framework. So-called "ParamConverters" can automagically fetch (ORM) Entities for request parameters and pass those into Controller classes, reducing boilerplate code. It would be great if we could make this work as well for "resolved target entities".