src/Transfer/EzPlatform/Repository/Manager/UserManager.php
protected function assignUserToUserGroups(User $user, array $userGroupObjects)
    {
        $ezUserGroups = [];
        foreach ($userGroupObjects as $userGroup) {
            $userGroup = $this->userGroupManager->createOrUpdate($userGroup);
            if ($userGroup instanceof UserGroupObject) {
                $ezUserGroup = $this->userGroupManager->find($userGroup);
                if ($ezUserGroup) {
                    $ezUserGroups[$ezUserGroup->id] = $ezUserGroup;
                    try {
                        $this->userService->assignUserToUserGroup($user, $ezUserGroup);
                    } catch (InvalidArgumentException $alreadyAssignedException) {
                        // Ignore error about: user already assigned to usergroup.
                    }
                }
            }
        }

        return $ezUserGroups;
    }
protected function assignUserToUserGroups(User $user, array $userGroupObjects)
    {
        $ezUserGroups = [];
        foreach ($userGroupObjects as $userGroup) {
            $userGroup = $this->userGroupManager->createOrUpdate($userGroup);
            if ($userGroup instanceof UserGroupObject) {
                $ezUserGroup = $this->userGroupManager->find($userGroup);
                if ($ezUserGroup) {
                    $ezUserGroups[$ezUserGroup->id] = $ezUserGroup;
                    try {
                        $this->userService->assignUserToUserGroup($user, $ezUserGroup);
                    } catch (InvalidArgumentException $alreadyAssignedException) {
                        // Ignore error about: user already assigned to usergroup.
                    }
                }
            }
        }

        return $ezUserGroups;
    }
protected function assignUserToUserGroups ( User $ user , array $ userGroupObjects ) { $ ezUserGroups = [ ] ; foreach ( $ userGroupObjects as $ userGroup ) { $ userGroup = $ this -> userGroupManager -> createOrUpdate ( $ userGroup ) ; if ( $ userGroup instanceof UserGroupObject ) { $ ezUserGroup = $ this -> userGroupManager -> find ( $ userGroup ) ; if ( $ ezUserGroup ) { $ ezUserGroups [ $ ezUserGroup -> id ] = $ ezUserGroup ; try { $ this -> userService -> assignUserToUserGroup ( $ user , $ ezUserGroup ) ; } catch ( InvalidArgumentException $ alreadyAssignedException ) { // Ignore error about: user already assigned to usergroup. } } } } return $ ezUserGroups ; }
Assigns a collection of Transfer user groups from an eZ user, and returns the once who were added.

@param User              $user
@param UserGroupObject[] $userGroupObjects

@return UserGroup[]
Assigns a collection of Transfer user groups from an eZ user and returns the once who were added .