我正在开发基于 YII 模块的应用程序
需要限制用户的某些操作以及整个模块
我能够限制用户'expression' + callback在规则中使用,但现在我想对两个不同的操作使用相同的回调函数,即我有一个回调函数,我想获取参数值并根据它评估要执行的操作,这里是我已经做了什么
public function accessRules()
    {
        return array(
            array('allow',  // allow all users to perform 'index' and 'view' actions
                'actions'=>array('index'),
                'users'=>array('*'),
                'expression'=>array($this, "checkAccessRule"),
            ),
            array('allow',  // allow all users to perform 'index' and 'view' actions
                'actions'=>array('login'),
                'users'=>array('?'),
            ),
            array('allow', // allow authenticated user to perform 'create' and 'update' actions
                'actions'=>array('view','create','update','admin','delete'),
                'users'=>array('@'),
                'expression'=>array($this, "checkAccessRule"), 
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }
回调函数
function checkAccessRule($op){ 
        if($op == 1){
            if(in_array($this->module->getName(), Yii::app()->user->getState("companyModules")))
                return true;
            return false;
        }elseif($op == 2){
            if((Yii::app()->user->getState("user_role") == 1) && (in_array($this->module->getName(), Yii::app()->user->getState("companyModules"))))
                return true;
            return false;
        }
    }
如果我发送它,则无法从回调中获取此“$ op”'expression'=>array($this, "checkAccessRule(1)"),
任何帮助,将不胜感激