Neos.Neos/Classes/Domain/Service/UserService.php
public function setRolesForAccount(Account $account, array $newRoleIdentifiers)
    {
        $currentRoles = $account->getRoles();

        foreach ($currentRoles as $roleIdentifier => $role) {
            $roleIdentifier = $this->normalizeRoleIdentifier($roleIdentifier);
            if (!in_array($roleIdentifier, $newRoleIdentifiers)) {
                $this->removeRoleFromAccount($account, $roleIdentifier);
            }
        }

        foreach ($newRoleIdentifiers as $roleIdentifier) {
            if (!in_array($roleIdentifier, array_keys($currentRoles))) {
                $this->addRoleToAccount($account, $roleIdentifier);
            }
        }
    }
public function setRolesForAccount(Account $account, array $newRoleIdentifiers)
    {
        $currentRoles = $account->getRoles();

        foreach ($currentRoles as $roleIdentifier => $role) {
            $roleIdentifier = $this->normalizeRoleIdentifier($roleIdentifier);
            if (!in_array($roleIdentifier, $newRoleIdentifiers)) {
                $this->removeRoleFromAccount($account, $roleIdentifier);
            }
        }

        foreach ($newRoleIdentifiers as $roleIdentifier) {
            if (!in_array($roleIdentifier, array_keys($currentRoles))) {
                $this->addRoleToAccount($account, $roleIdentifier);
            }
        }
    }
public function setRolesForAccount ( Account $ account , array $ newRoleIdentifiers ) { $ currentRoles = $ account -> getRoles ( ) ; foreach ( $ currentRoles as $ roleIdentifier => $ role ) { $ roleIdentifier = $ this -> normalizeRoleIdentifier ( $ roleIdentifier ) ; if ( ! in_array ( $ roleIdentifier , $ newRoleIdentifiers ) ) { $ this -> removeRoleFromAccount ( $ account , $ roleIdentifier ) ; } } foreach ( $ newRoleIdentifiers as $ roleIdentifier ) { if ( ! in_array ( $ roleIdentifier , array_keys ( $ currentRoles ) ) ) { $ this -> addRoleToAccount ( $ account , $ roleIdentifier ) ; } } }
Overrides any assigned roles of the given account and potentially carries out further actions which are needed
to properly reflect these changes.

@param Account $account The account to assign the roles to
@param array $newRoleIdentifiers A list of fully qualified role identifiers, or role identifiers relative to the Neos.Neos namespace
@return void
@api
Overrides any assigned roles of the given account and potentially carries out further actions which are needed to properly reflect these changes .