Neos\Flow\Security\Account::removeRole PHP Method

removeRole() public method

Removes a role from this account
public removeRole ( Role $role ) : void
$role Neos\Flow\Security\Policy\Role
return void
    public function removeRole(Role $role)
    {
        $this->initializeRoles();
        if ($this->hasRole($role)) {
            $roleIdentifier = $role->getIdentifier();
            unset($this->roles[$roleIdentifier]);
            $identifierIndex = array_search($roleIdentifier, $this->roleIdentifiers);
            unset($this->roleIdentifiers[$identifierIndex]);
        }
    }

Usage Example

コード例 #1
0
 /**
  * @test
  */
 public function removeRoleSkipsRemovalIfRoleNotAssigned()
 {
     $this->account->setRoles([$this->administratorRole]);
     $this->account->removeRole($this->customerRole);
     $this->assertCount(1, $this->account->getRoles());
 }
All Usage Examples Of Neos\Flow\Security\Account::removeRole