A
A
Anton Natarov2016-07-19 14:15:29
Yii
Anton Natarov, 2016-07-19 14:15:29

How to set behavior for the whole application or module in yii2?

I have a global dynamic behavior that checks for a role and issues permissions.
now I have to write the following construction in each admin controller for verification:

use developeruz\db_rbac\behaviors\AccessBehavior;

 'as AccessBehavior' => [
        'class' => AccessBehavior::className(),
 ]

I 'm using the Advanced architecture and this is an extension. Is it possible to set the behavior on the Backend completely (so as not to write accesses in each controller, but close the admin panel at once) or on a module for example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-07-19
@HanDroid

no, this cannot be done. You can:
1. Either connect the behavior in the config
2. Or define the behavior in the parent class (separately for each controller, module, etc.)
3. Or attach dynamically to the called controller in each module
https://github.com/ yiisoft/yii2/blob/master/docs/g...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question