oauth2-bundle icon indicating copy to clipboard operation
oauth2-bundle copied to clipboard

[Question] - Integrate with infrastructure layer other that doctrine.

Open jpmarques66 opened this issue 4 years ago • 4 comments

Hi guys, first of all, great work here. 🎉

I've been going around the documentation and the code but I can't seem to find anywhere that indicates how to configure persistence in detail.

Is it possible to set up a different persistence mechanism other than doctrine/in_memory? If so, how would one proceed to do that?

Base config

  # Only one persistence method can be configured at a time.
    persistence:          # Required
        doctrine:

            # Name of the entity manager that you wish to use for managing clients and tokens.
            entity_manager:       default
        in_memory:            ~

jpmarques66 avatar Apr 15 '20 18:04 jpmarques66

@jpmarques66 Hi, currently only these two persistence mechanism are supported out of the box. However, if you wish to use a different one, you should be able to implement it in your application.

HypeMC avatar Apr 16 '20 21:04 HypeMC

@HypeMC Thanks for the answer! How would one do that? The only possible way that I'm seeing is implementing my own Doctrine Entity Manager and pass it here. Is this the only way, or am I missing something?

persistence:   
        doctrine:
            entity_manager:       MyEntityManager

Thanks in advance.

jpmarques66 avatar Apr 17 '20 14:04 jpmarques66

Well, implementing your own persistence mechanism doesn't seem like an easy task to do. As far as I see, the only two available methods are baked in (see the bundle extension):

        switch ($persistenceMethod) {
            case 'in_memory':
                $loader->load('storage/in_memory.xml');
                $this->configureInMemoryPersistence($container);
                break;
            case 'doctrine':
                $loader->load('storage/doctrine.xml');
                $this->configureDoctrinePersistence($container, $persistenceConfiguration);
                break;
        }

What I would suggest here is maybe centralize the persistence layer in one or several interfaces and add a service persistence method that would accept one or several service IDs that would handle persistence. @jpmarques66, I'm not sure if this is any help but you might want to share your opinion as well.

kix avatar Mar 24 '21 15:03 kix

Please also add documentation regarding the configuration in_memory persistence mechanism.

smilesrg avatar Sep 03 '21 08:09 smilesrg