Set ZF2 BjyAuthorize controller guards from Doctrine Entity

131 views Asked by At

I have found a lot of questions on net that answers about setting controller guards directly in the config file but a lot less for getting the values from Doctrine Entity.

Can anyone please let me know about a single article that explains the process enough to start with.

I have already referred - ZF2 - BjyAuthorize - How to Get Rules and Guards from a Database

But no help in understanding where exactly should I register DoctrineControllerGuardAdapterFactory in the module config file.

Any help is appreciated.

1

There are 1 answers

0
Kunal Dethe On

Need the following settings -

'guards' => array(
    'YOUR_MODULE_NAME_controller_guard_adapter' => array(
        'object_manager' => 'doctrine.entity_manager.orm_default',
        'rule_entity_class' => 'YOUR_MODULE_NAME\Entity\RULE_ENTITY_NAME'
    ),
),
'service_manager' => array(
    'factories' => array(
        'YOUR_MODULE_NAME_controller_guard_adapter' => 'YOUR_MODULE_NAME\Factory\DoctrineControllerGuardAdapterFactory',
    ),
),

Now the factory will inject the rules in the BjyAuthorize\Guard\Controller constructor as mentioned in the ZF2 - BjyAuthorize - How to Get Rules and Guards from a Database link.