Neos.Neos/Classes/Domain/Service/UserService.php
public function addRoleToAccount(Account $account, $roleIdentifier)
    {
        $roleIdentifier = $this->normalizeRoleIdentifier($roleIdentifier);
        $role = $this->policyService->getRole($roleIdentifier);

        if (!$account->hasRole($role)) {
            $account->addRole($role);
            $this->accountRepository->update($account);
            $this->emitRolesAdded($account, [$role]);

            return 1;
        }

        return 0;
    }
public function addRoleToAccount(Account $account, $roleIdentifier)
    {
        $roleIdentifier = $this->normalizeRoleIdentifier($roleIdentifier);
        $role = $this->policyService->getRole($roleIdentifier);

        if (!$account->hasRole($role)) {
            $account->addRole($role);
            $this->accountRepository->update($account);
            $this->emitRolesAdded($account, [$role]);

            return 1;
        }

        return 0;
    }
public function addRoleToAccount ( Account $ account , $ roleIdentifier ) { $ roleIdentifier = $ this -> normalizeRoleIdentifier ( $ roleIdentifier ) ; $ role = $ this -> policyService -> getRole ( $ roleIdentifier ) ; if ( ! $ account -> hasRole ( $ role ) ) { $ account -> addRole ( $ role ) ; $ this -> accountRepository -> update ( $ account ) ; $ this -> emitRolesAdded ( $ account , [ $ role ] ) ; return 1 ; } return 0 ; }
Adds the specified role to the given account and potentially carries out further actions which are needed to
properly reflect these changes.

@param Account $account The account to add roles to
@param string $roleIdentifier A fully qualified role identifier, or a role identifier relative to the Neos.Neos namespace
@return integer How often this role has been added to the given account (effectively can be 1 or 0)
@api
Adds the specified role to the given account and potentially carries out further actions which are needed to properly reflect these changes .