Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii:Restfullyii扩展访问restEvents规则_Php_Rest_Yii - Fatal编程技术网

Php Yii:Restfullyii扩展访问restEvents规则

Php Yii:Restfullyii扩展访问restEvents规则,php,rest,yii,Php,Rest,Yii,他在那里, 我已经使用restfullyii扩展一段时间了,一切都很好。 () 我只是想知道是否有以下可能: 管理员可以执行所有REST.GET、REST.PUT、REST.POST和REST.DELETE 普通用户只能在restEvents中使用自己定义的 accessRules如下所示: public function accessRules() { return array( array('allow', 'actions'=>a

他在那里,

我已经使用restfullyii扩展一段时间了,一切都很好。 ()

我只是想知道是否有以下可能:

  • 管理员可以执行所有REST.GET、REST.PUT、REST.POST和REST.DELETE
  • 普通用户只能在restEvents中使用自己定义的
accessRules如下所示:

public function accessRules()
{
    return array(
        array('allow', 
            'actions'=>array('REST.GET.SPECIAL'),
            'users'=>array('@'),
        ),
        array('allow', // allow admin user to perform 'admin' actions
            'actions'=>array('REST.GET', 'REST.PUT', 'REST.POST', 'REST.DELETE'),
            'users'=>Yii::app()->getModule('user')->getAdmins(),
        ),
        array('deny',  // deny all users
            'users'=>array('*'),
        ),
    );
}
public function restEvents()
{ 
    $this->onRest('req.get.special.render', function() {
        /// blabla code
    });
}
restEvents的外观如下所示:

public function accessRules()
{
    return array(
        array('allow', 
            'actions'=>array('REST.GET.SPECIAL'),
            'users'=>array('@'),
        ),
        array('allow', // allow admin user to perform 'admin' actions
            'actions'=>array('REST.GET', 'REST.PUT', 'REST.POST', 'REST.DELETE'),
            'users'=>Yii::app()->getModule('user')->getAdmins(),
        ),
        array('deny',  // deny all users
            'users'=>array('*'),
        ),
    );
}
public function restEvents()
{ 
    $this->onRest('req.get.special.render', function() {
        /// blabla code
    });
}
我似乎在文档中找不到它


非常感谢

我用以下方法解决了这个问题:

 /**
 * req.auth.uri
 *
 * return true to allow access to a given uri / http verb;
 * false to deny access to a given uri / http verb;
 *
 * @return (bool) default is true
 */ 
$this->onRest(req.auth.uri, function($uri, $verb) {
    return true;
});
这将允许您阻止/允许控制器中的特定用户。只需将其放在restEvents()方法中