You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
E.g. in the FOSUserBundle, one inherits from a Doctrine User entity that is configured via an XML file instead of annotations like we expect in the doctrine-orm-test-infrastructure. For now, these configuration files are ignored, which leads to errors like "unrecognized field: username".
Duplicating the configuration in annotation form is no workaround, as this leads to other errors (field is already defined).
It would be great to allow passing configuration files to ORMInfrastructure::create*. Even better, but not urgent, would be an auto-discover of these configuration files.
The text was updated successfully, but these errors were encountered:
That was one question that came up during the Symfony User Group the other day...
Currently, the ORMInfrastructure works without further ado because it can find the classes in code and so it can discover annotations as well. But if configuration is kept in XML files, it has no way of knowing where to look for those, right?
Looking in OrmInfrastructure::createEntityManager, it creates the EntityManager configuration via ConfigurationFactory::createFor, which has the AnnotationDriver hardcoded. It also discovers directory paths via the PHP reflection API. To support XML (or any) mappings, ConnectionConfiguration should, just like Doctrine's EntityManager::create, accept a second parameter \Doctrine\ORM\Configuration $config.
But looking closer in ConfigurationFactory::createFor it does two things which would not be enforced if the connection would be opened for injection:
It hardcodes devMode = true, proxyDir = null and an array cache.
It creates EntityListDriverDecorator, which decorates the created annotation driver.
Therefore, instead of a \Doctrine\ORM\Configuration, the second parameter to ConnectionConfiguration should be an (optional) mapping driver. I'll be looking into it at the weekend.
While we're at it, maybe ConnectionConfiguration should be renamed to Configuration, because it would no longer be exclusive to connection configuration.
E.g. in the FOSUserBundle, one inherits from a Doctrine User entity that is configured via an XML file instead of annotations like we expect in the doctrine-orm-test-infrastructure. For now, these configuration files are ignored, which leads to errors like "unrecognized field: username".
Duplicating the configuration in annotation form is no workaround, as this leads to other errors (field is already defined).
It would be great to allow passing configuration files to ORMInfrastructure::create*. Even better, but not urgent, would be an auto-discover of these configuration files.
The text was updated successfully, but these errors were encountered: