If I understand you clearly, you want to use the Yii2 RBAC Rule to implement some permissions for system users (Admin and encoder). Well, it's pretty straight to some extent
Yii2 has existing tables for this purpose. These tables are me. auth_assignment II. auth_item III. auth_item_child intravenously auth_rule
The first thing you need to do is choose which authManager you want to use either PhpManager or DBManager, but I would advise you to use the DBManager argument, which is what I use
If you are using the Yii2 Basic template, add the following lines of code below the components in web.php
'authManager' => [ 'class' => 'yii\rbac\DbManager', 'defaultRoles' => ['guest'], ],
If the Yii2 Advanced Template , add the lines of code below under the components in main.php inside the \ common \ config folder
By doing the above steps,
- Run yii migrate --migrationPath = @ yii / rbac / migrations from the command line
The above code will generate / create four tables that were previously listed automatically inside the database for you
To create your own RBAC rules.
This requires the creation of permissions and roles.
For the base template
- Create a file and name it RbacController.php inside the command folder
See http://pastebin.com/RAKpZX2J to see how it looks.
For an extended template, - Create the same file, but instead it will be located inside the console \ controllers \ RbacController.php
Having done all this
- Run yii rbac / init // This willl run actionInit () inside the RbacController file
if you have successfully created all of the above, you can do something like this to find out if the user has permission
if(Yii::$app->user->can('createUser')){ }
I hope this helps.