How can I move my zfc-rbac guard config into Doctrine?

177 views Asked by At

I have permissions and roles built into an admin inside of zf2. I want to move the guards from the config file to the db.

I see there is a GuardInterface but I don't see a guide in the zfc-rbac docs. https://github.com/ZF-Commons/zfc-rbac/blob/master/docs/04.%20Guards.md

I've tried mirroring the implementation of a role provider, I don't get any errors but the guards do not seem to be initiating.

Is there a guide I can follow to help me implement this?

1

There are 1 answers

2
Tim Klever On

There's a couple ways you can go about this.

You can get straight to the point and replace the GuardFactory, and instead of loading your guards from module options, you can load them from your DB.

However, that seems a little ugly, and could lead to confusion (as the guards module option would still exist).

Your second choice, is to override the ModuleOptionsFactory (and potentially ModuleOptions itself) to pull the Guard config array from your DB and not the config file.

Your third option is to wrap everything that accesses the guards in some kind of "GuardProviderInterface" and put your DB behind that, but this option is the most significant amount of work, with the most touch points and refactoring.