/** * Revokes a roles and permissions from the user. * * @param array $items * * @return int number of successful revoke */ public function revoke($items) { foreach ($items as $name) { $item = $this->manager->getRole($name); $item = $item ?: $this->manager->getPermission($name); $this->manager->revoke($item, $this->userId); } return true; }
/** * Remove roles. */ protected function removeRoles() { if (!($roles = ArrayHelper::getValue($this->rbac, 'roles'))) { return; } foreach ($roles as $name => $children) { if (!($role = $this->_auth->getRole($name))) { continue; } foreach ($children as $childName) { if ($permission = ArrayHelper::getValue($this->_permissions, $childName)) { $this->_auth->removeChild($role, $permission); } elseif ($childRole = $this->_auth->getRole($childName)) { $this->_auth->removeChild($role, $childRole); } } $this->_auth->remove($role); $userIds = $this->_auth->getUserIdsByRole($name); foreach ($userIds as $userId) { $this->_auth->revoke($role, $userId); } } }