a2lix / AutoFormBundle

Automate Symfony form building
https://a2lix.fr/bundles/auto-form
MIT License
83 stars 30 forks source link

Multiple entity managers #39

Open h3llr4iser opened 1 year ago

h3llr4iser commented 1 year ago

This PR enhances the DoctrineORMInfo class in the A2lix\AutoFormBundle to better support applications that use multiple Doctrine entity managers.

Previously, this class was directly creating an EntityManager which can cause compatibility issues when the application requires different EntityManager instances for different classes.

Now, the DoctrineORMInfo service utilizes the ManagerRegistry service. The ManagerRegistry service is used to retrieve the appropriate EntityManager for a given class. This allows for better compatibility with applications that use multiple entity managers.

The changes include:

Replaced the ClassMetadataFactory with the ManagerRegistry in DoctrineORMInfo.
Updated the methods getFieldsConfig, getAssociationTargetClass, getAssocsConfig and getMetadata to use the new manager registry.
Updated the DoctrineORMInfo service definition.
Updated test cases to reflect these changes.

The PR addresses the problem raised in issue #16 .