-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Cannot override the class metadata factory via configuration since 3.0 #11496
Comments
Obviously not a bug. Please elaborate your use-case. |
As explained also in the ODM issue:
I used this feature in 2.x without any problem, but defining the concrete type into the EntityManager does not allow to use any other class implementing the common interface/extending the abstract class. |
You did not answer the question. |
Yes, I did. My use-case is to create a fake/mock version of the class metadata factory implementing In the current state calling What else do you need to know precisely? |
As far as I know, our factory is not final, so you may still mock it. |
The class itself is not final, but some of the public methods are final in I'm currently replacing the class completely, just implementing the interface. |
I see. Well, we could introduce a new interface for our factory that you can mock. Please send a PR. |
👍 Ok, thanks. I'll send it tomorrow. |
I was wondering about the interface introduced in #11497. It seems that it contains the rest of the public methods that were added to the |
@SenseException I agree with your objections, but the same applies to the The meaning of that interface is to create a minimum set of methods used by the ORM that needs to be implemented in order to override the metadata factory. I don't know if this could be split easily; maybe the setters could be avoided passing them to the factory constructor, but in this case you can't just customise the factory class name in configuration, but you need to set into the configuration object at least a closure that creates the factory. |
Bug Report
Summary
Since version 3.0.0, the class metadata factory cannot be overridden.
Previous behavior
The entity manager has been instantiated taking the class name from the configuration on entity manager construction
Current behavior
Since ea97ea4 the override is broken as the entity manager is wired to the class
Doctrine\ORM\Mapping\ClassMetadataFactory
.To allow overriding via configuration, it should be wired against
Doctrine\Persistence\Mapping\ClassMetadataFactory
interface.How to reproduce
This is the same exact bug reported on mongodb-odm at doctrine/mongodb-odm#2551
The only difference is that on mongodb-odm this was considered a BC break, as the bug was introduced in a minor version.
The text was updated successfully, but these errors were encountered: