0
votes

I have two modules. 1) User Module and 2) RbacUser Module. RbacUser Module is depended on User Module. I extend my "User entity" from User Module in RbacUser Module and add some new attributes to User Entity like roles etc.

What i am to do is, When i used RbacUser Module, make RbacUser Module User Entity default. So schema tool know that which entity should use to create table ?

In Short Words:

if Only User Module is used then make its User Entity Default

or

if RbacUser Module is used then make its User Entity Default and ignore User's entity.


I found the solution

These are the configuration of my both modules

User Module Config file

User\Config\module.config.php
'driver' => array(
        'user_driver' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            'cache' => 'array',
            'paths' => array(
                __DIR__.'/../src/User/Entity',
            ),
        ),
        'orm_default' => array(
            'drivers' => array(
                'User\Entity\User' => 'user_driver'
            )
        )
    ),

RbacUser Module config file

RbacUser\Config\module.config.php
'doctrine' => array(
    'driver' => array(
        'rbacuser_driver' => array(
            'class' => 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver',
            'cache' => 'array',
            'paths' => array(
                __DIR__.'/../src/RbacUser/Entity',
            ),
        ),
        'orm_default' => array(
            'drivers' => array(
                'RbacUser\Entity\User' => 'rbacuser_driver'
            )
        )
    )
)

If i don't use "User" Module doctrine driver config then my problem is solved. Is their any way to check if RbacUser Module is used then don't use doctrine driver configuration in "User" Module

1
"Is their any way to check if RbacUser Module is used then don't use doctrine driver configuration in "User" Module" : you could check if the key $config['doctrine']['driver']['rbacuser_driver'] exists in the config service.jmleroux
yes i can do this. But when i run command from cli to update my schema like this, doctrine-module orm:schema-tool:update --force then this command display error that user table already exist.Aneeq Tariq
one solution i find is that, if $config['doctrine']['driver']['rbacuser_driver'] key exist then Read the User\Config\module.config.php configuration file through \zend\config\config and modify the configuration and write back to User\Config\module.config.php file through zend\config\writer . Is this methodology is correct or any other methodolgy should be adopted. My primary reason is to make module reusable so i can drop this module in my application and just update schema thats it.Aneeq Tariq

1 Answers

0
votes

You must implement an IdentityProvider in your RbacUser module and specify this configuration key