yii\rbac\ManagerInterface::revoke PHP Method

revoke() public method

Revokes a role from a user.
public revoke ( Role $role, string | integer $userId ) : boolean
$role Role
$userId string | integer the user ID (see [[\yii\web\User::id]])
return boolean whether the revoking is successful
    public function revoke($role, $userId);

Usage Example

Example #1
0
 /**
  * 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;
 }
All Usage Examples Of yii\rbac\ManagerInterface::revoke