public function addUsersToGroup(Group $group, array $users)
    {
        $addedUsers = [];

        if (!$this->validateAddUsersToGroup($users, $group)) {
            throw new Exception\AddRoleException();
        }

        foreach ($users as $user) {
            if (!$group->containsUser($user)) {
                $addedUsers[] = $user;
                $group->addUser($user);
                $this->eventDispatcher->dispatch('log', 'Log\LogGroupAddUser', [$group, $user]);
            }
        }

        $this->om->persist($group);
        $this->om->flush();

        return $addedUsers;
    }
public function addUsersToGroup(Group $group, array $users)
    {
        $addedUsers = [];

        if (!$this->validateAddUsersToGroup($users, $group)) {
            throw new Exception\AddRoleException();
        }

        foreach ($users as $user) {
            if (!$group->containsUser($user)) {
                $addedUsers[] = $user;
                $group->addUser($user);
                $this->eventDispatcher->dispatch('log', 'Log\LogGroupAddUser', [$group, $user]);
            }
        }

        $this->om->persist($group);
        $this->om->flush();

        return $addedUsers;
    }
public function addUsersToGroup ( Group $ group , array $ users ) { $ addedUsers = [ ] ; if ( ! $ this -> validateAddUsersToGroup ( $ users , $ group ) ) { throw new Exception \ AddRoleException ( ) ; } foreach ( $ users as $ user ) { if ( ! $ group -> containsUser ( $ user ) ) { $ addedUsers [ ] = $ user ; $ group -> addUser ( $ user ) ; $ this -> eventDispatcher -> dispatch ( 'log' , 'Log\LogGroupAddUser' , [ $ group , $ user ] ) ; } } $ this -> om -> persist ( $ group ) ; $ this -> om -> flush ( ) ; return $ addedUsers ; }
Adds an array of user to a group.

@param Group  $group
@param User[] $users

@return User[]

@throws Exception\AddRoleException
Adds an array of user to a group .