Switch what manager is the DefaultManager dynamically #73

Closed
dantleech opened this Issue Jun 21, 2013 · 16 comments

Comments

Projects
None yet
4 participants
Contributor

dantleech commented Jun 21, 2013

We need to be able to change the default manager name on the ManagerRegistry to enable, for example, changing from Preview ro Staging workspaces depending on the domain.

We can currently do this by hacking the PHPCR-ODM ManagerRegistry and returning and modifying our own defaultManagerName.

Contributor

dantleech commented Jun 21, 2013

To fix this "propertly" we need to add "setDefaultManager" to ManagerRegistry in doctrine commons:

Issue: http://www.doctrine-project.org/jira/browse/DCOM-203

/cc @fazy, @lsmith77

Member

dbu commented Jun 22, 2013

that is going to take time until it will be possible, even if the doctrine crowd agrees.

so for now we need to keep track of who is using the manager and update them all? alternatively we could extend the ManagerRegistry and try to hide the private defaultManagerName with our own field that has a setDefaultManager method. could be a bit hackish but should not be too bad i think.

Member

lsmith77 commented Jun 24, 2013

we discussed this and felt it was a relevant enough use case to support it. going through and updating the document manager everywhere seems like a lot of overhead .. especially since many of these services will in the end not get called again to actually do something with the new document manager. furthermore its hard to know which service has actually decided on its own to use a different document manager for some reason.

as such we decided that it would be best to completely override the "default" connection and manager in the ManagerRegistry (as it is private) atm. it will mean some additional code in our ManagerRegistry implementation but not a lot of logic. we will then also submit a PR for Symfony 2.4 to make this a core feature.

/cc @stof @beberlei

Owner

beberlei commented Jun 24, 2013

This is a problem the DIC has to solve, not the registry

Member

lsmith77 commented Jun 24, 2013

Not sure how the DIC can help here. In a sense we are using the ManagerRegistry as a more limited DIC (or rather service locator). We need to be able to change the document manager multiple times if needed within the same request.

Owner

beberlei commented Jun 24, 2013

Ah ok i get the requirement now. Not sure if hacking the "default" feature here is a good way, as this is a different concept than having a "staging" and "live" database, which are valid domain concepts in the CMS world.

Contributor

dantleech commented Jun 26, 2013

Could the developer simply supply a different implementation of the PHPCR manager registry that could infer the workspace from something (i.e. the request or a custom class) ? /cc @fazy

Member

dbu commented Jun 27, 2013

that sounds like a quite interesting idea!

Member

lsmith77 commented Aug 18, 2013

ping

Member

dbu commented Mar 1, 2014

ping again. as we are nearing the 1.1 release, this would be a moment to introduce this.

Member

dbu commented Mar 14, 2014

i think the way to go is simply to extend Doctrine\Bundle\PHPCRBundle\ManagerRegistry and then configure doctrine_phpcr.class so nothing needs to be done in the bundle. does that make sense?

Member

lsmith77 commented Aug 25, 2014

but we currently do not make this class configurable from what I can tell .. so that should be done.

Member

dbu commented Aug 25, 2014

Member

lsmith77 commented Aug 25, 2014

yes .. but it is not configurable via the Bundle config .. overwriting DI parameters of Bundles is not a good idea

Member

lsmith77 commented Aug 25, 2014

see #165

Member

dbu commented Dec 5, 2014

fixed in #165

@dbu dbu closed this Dec 5, 2014

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