Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii access control filter rules in controllers

Tags:

yii

When writing rules for access control in yii controllers, possible parameters to be set for a rule are 'action' - sets to which action the rule applies; 'users', 'roles', etc.

Now, both the yii guide (pdf) and reference (I have chm file) say that it's possible to set, also, a controller id for the controller the rule should apply to.

Now, if we are already putting these rules in a controller class/file, how would we be able to put some other controller (other than the current one) as the parameter here, meaning how would some other controller whose id we mention here - how would it know there is a rule that applies to it, since it's written in a completely other controller class/file?

How would the controller be aware of a rule that mentions it, if it's written outside of it, in a completely different controller?

like image 844
tonino.j Avatar asked Oct 18 '10 21:10

tonino.j


1 Answers

You can hook into CWebApplication::beforeControllerAction() to apply filters before the controller even gets the request.

~thinkt4nk

like image 143
Ryan Bales Avatar answered Sep 30 '22 00:09

Ryan Bales