Skip to content
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

Ability to (auto)load entity configuration via XML/YML files #14

Open
MalteWunsch opened this issue Apr 18, 2016 · 3 comments
Open

Ability to (auto)load entity configuration via XML/YML files #14

MalteWunsch opened this issue Apr 18, 2016 · 3 comments

Comments

@MalteWunsch
Copy link
Member

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.

@mpdude
Copy link
Member

mpdude commented Oct 19, 2017

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?

@apapsch
Copy link

apapsch commented Jun 22, 2018

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.

@mpdude
Copy link
Member

mpdude commented Feb 27, 2024

Please check if #48 solves this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants