-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Added registry service #158
Conversation
@Spea I'm not sure about what this is for... |
I recently created a module for the JMS serializer library. There I have the possibility to use some specific metadata driver for doctrine (see here). As you can see I need an object of type ManagerRegistry for this driver. Of course I could create this service in the module itself, but I think it makes more sense to implemente it in the ORM module directly. |
@Spea the idea is nice, but shouldn't this:
I think only the factory fits the ORM module. Can you also add test coverage for these classes please? |
@@ -22,6 +22,7 @@ | |||
'Doctrine\ORM\EntityManager' => 'doctrine.entitymanager.orm_default', | |||
), | |||
'factories' => array( | |||
'doctrine' => new DoctrineORMModule\Service\RegistryFactory(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably be doctrine.registry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if there is no config to be passed to the RegistryFactory
, this can be a string:
'doctrine' => 'DoctrineORMModule\Service\RegistryFactory',
I will create a new PR for the registry class in the DoctrineModule then. I also add some tests for the factory. |
@Spea thank you. Please think carefully about how to handle the registry, since ORM and ODM have different keys, and we ideally would want to have a single registry (or at least a registry that knows of any defined EMs/DMs) |
I'm not sure about the naming. In the symfony2 bundles the registry services are called |
The registry class is always somehow specific when it comes to alias namespaces. I can put the basic parts into the DoctrineModule, but in the end the ORM/ODM module must extend this registry class and implement the |
@Spea I'd use a single registry. After all, anything depending on DoctrineModule only should not make ANY assumptions about the implementation of the ObjectManager. Here's how it could work: return new ManagerRegistry(array(
'doctrine.entitymanager',
'doctrine.documentmanager',
'doctrine.contentmanager', //example for PHPCR
'doctrine.graphmanager', // example for OrientDB ODM
)); The problem is indeed the return new ManagerRegistry(array(
'doctrine.entitymanager' => 'doctrine.configuration',
'doctrine.documentmanager' => 'doctrine.configuration',
'doctrine.contentmanager' => 'doctrine.configuration', //example for PHPCR
'doctrine.graphmanager' => 'doctrine.configuration', // example for OrientDB ODM
)); Good that this came out now, since I also notice all these collisions. @superdweebie any ideas? |
The problem with a single registry also is, that it would be impossible to pass a default connection to the registry (which one should be used). |
@Spea that is up to the user configuring it I suppose. We can add defaults in the ODM and ORM modules. Last module wins :) |
I'm closing this after having discussed it a bit with internals. All this registry stuff is basically convoluted, and is here because we still have no clear DI policy in core. There's some movement in data-fixtures, but so far, this is way too hacky, and I prefer not to have this in here. |
Almost 1 year on, is there another solution for this? I have the same issue as @Spea, I wish to use DoctrineTypeDriver with JMS serialiser library, but unable to get the ManagerRegistry |
@eddiejaoude while it isn't in |
I just wanted to check that nothing official has been done. Yes, I will use the diff as an example. Thanks. |
ZF2 Module on packagist to get |
This PR adds a new service
doctrine