Answer the question
In order to leave comments, you need to log in
How to implement dynamic loading actions?
Hello.
What do you think is the best way to implement access to Actions from the database in Yii2?
Let's say there are 5 actions in total:
Answer the question
In order to leave comments, you need to log in
The controller has an actions() method that partially defines the list of actions available in the controller. You can put all actions in Standalone classes , make a base class, inside which you can check if there is access to this action.
But I would be interested to hear why you need such a solution at all? There are a lot of access control tools out there! Yes, take at least RBAC .
yii\filters\AccessControl
https://www.yiiframework.com/doc/api/2.0/yii-filte...
You pass the actions array to it, so all that's left is to add your logic for forming this array.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question