accessRules context parameter method

I’m working on access control for a controller and have rules that look like this:

array('allow', 'actions' => array('edit', 'delete'), 'users' => array('@')),

Is there a way to check with a method to see if the user has sufficient permissions? For example, I’d like a function to be run before a particular action to check two or three criteria to see if the user is authorized to access the action.

You have two(+) options here.

  1. You can use the ‘expression’ of each access rule to define an anonymous function that will be run before each time the action is requested: and

  2. Use Role Based Access Control (RBAC), and then use the method checkAccess:


Thanks! Here is my solution:

public function accessRules()


	return array(



			'expression' => array($this, 'checkAccessForAdmin')





public function checkAccessForAdmin($user, $rule)


        //return true or false

	return true;