コード例 #1
0
 /**
  * 删除权限节点
  */
 protected function deletePermission($event)
 {
     $auth = Yii::$app->authManager;
     $model = $this->owner;
     $permission = $auth->getPermission($model->auth_item);
     $auth->remove($permission);
     if (!empty($model->auth_rules)) {
         $authRules = $model->auth_rules;
         foreach ($authRules as $authRule) {
             if (!($rule = $auth->getRule($authRule))) {
                 $rule = Auth::getRuleObject($authRule);
                 $auth->add($rule);
             }
             $additionalPermission = $auth->getPermission($model->auth_item . '-' . $rule->name);
             $auth->remove($additionalPermission);
         }
     }
 }
コード例 #2
0
ファイル: Menu.php プロジェクト: phpdn/qc-base
 /**
  * @inheritdoc
  */
 public function controlAttributes()
 {
     return [['id' => 'basic', 'name' => '基本属性', 'attributes' => ['name' => ['type' => 'text'], 'parent_id' => ['type' => 'tree', 'pkAttrName' => 'menu_id', 'showAttrName' => 'name', 'items' => function () {
         return static::find()->asArray()->all();
     }, 'topItem' => [0 => '顶级菜单']], 'app' => ['type' => 'dropDown', 'items' => [App::className(), 'getAppsItems']], 'module' => ['type' => 'text'], 'controller' => ['type' => 'text'], 'action' => ['type' => 'text'], 'params' => ['type' => 'text', 'hint' => '额外附加到生成地址的参数,比如a=1&b=2'], 'sort' => ['type' => 'text'], 'type' => ['type' => 'dropDown', 'items' => [static::className(), 'getTypeItems']], 'auth_rules' => ['type' => 'checkbox', 'items' => [Auth::className(), 'getRuleItems']], 'remark' => ['type' => 'textarea'], 'status' => ['type' => 'radio', 'items' => [static::className(), 'getStatusItems']]]]];
 }