Note, the child item is not deleted. Only the parent-child relationship is removed.
public removeChild ( |
||
$parent | ||
$child | ||
Результат | boolean | whether the removal is successful |
public function actionAjaxChildRemove($name) { $role = $this->findRole($name); $namePermission = Yii::$app->request->post('permission'); $permission = $this->auth->getPermission($namePermission); return $this->auth->removeChild($role, $permission) ? 'success' : 'fail'; }
/** * Remove child from an item * * @param array $items * * @return int */ public function removeChildren($items) { if ($this->_item !== null) { foreach ($items as $name) { $child = $this->manager->getPermission($name); if (empty($child) && $this->type == Item::TYPE_ROLE) { $child = $this->manager->getRole($name); } $this->manager->removeChild($this->_item, $child); } } return true; }
/** * Remove permissions. */ protected function removePermissions() { if (!($permissions = ArrayHelper::getValue($this->rbac, 'permissions'))) { return; } $this->_permissions = []; foreach ($permissions as $name => $data) { if (!($permission = $this->_auth->getPermission($name))) { continue; } if (($childName = ArrayHelper::getValue($data, 'child')) && ($child = $this->_auth->getPermission($childName))) { $this->_auth->removeChild($permission, $child); } if ($ruleClass = ArrayHelper::getValue($data, 'rule')) { $rule = Yii::createObject($ruleClass); $this->_auth->remove($rule); } $this->_auth->remove($permission); $this->_permissions[$name] = $permission; } }
/** * @param string|Role $role * @return static */ public function removeRole($role) { $role = $this->findRole($role); $this->authManager->removeChild($this->item, $role); return $this; }