Suppose my application has two user tables(or two user system). one for back-end user, such as staff. another for front-end user.
They all need to have access control based on RBAC, so I decide to use one DbManager
for back-end user, and use another DbManager
for front-end user. such as:
//this configured in application(web.php) or front-end module(@app/modules/fontend/Module.php)
$app->setComponents([
'authManager' => [
'class' => yii\rbac\DbManager::class,
'itemTable' => 'frontend_auth_item_table',
'itemChildTable' => 'frontend_auth_item_child',
'assignmentTable' => 'frontend_auth_assignment',
'ruleTable' => 'frontend_auth_rule',
'cacheKey' => 'frontendRbac'
]
]);
//this configured in back-end module(@app/modules/backend/Module.php)
$this->setComponents([
'authManager' => [
'class' => yii\rbac\DbManager::class,
'itemTable' => 'backend_auth_item_table',
'itemChildTable' => 'backend_auth_item_child',
'assignmentTable' => 'backend_auth_assignment',
'ruleTable' => 'backend_auth_rule',
'cacheKey' => 'backendRbac'
]
]);
I need to create tables for them. But I can’t execute migration files in @yii/rbac/migrations
twice because that migration table has same class name history.
how can I do?
- Because I can’t have many same class name (or migraiton name) in one migration table, so I create new migration class and inherit migration class in
@yii/rbac/migrtions
? I also have to overwritegetAuthManager()
to get module authManager in new migration calss. - Create separated migration table and execute migration files in
@yii/rbac/migrations
as before, but I can’t changegetAuthManager()
in @yii/rbac/migration file.
any suggestion?