src/Sulu/Bundle/SecurityBundle/UserManager/UserManager.php
protected function processUserGroups(UserInterface $user, $userGroups)
    {
        $get = function($entity) {
            /* @var UserInterface $entity */
            return $entity->getId();
        };

        $delete = function($userGroup) use ($user) {
            $user->removeUserGroup($userGroup);
            $this->em->remove($userGroup);
        };

        $update = function($userGroup, $userGroupData) {
            return $this->updateUserGroup($userGroup, $userGroupData);
        };

        $add = function($userGroup) use ($user) {
            return $this->addUserGroup($user, $userGroup);
        };

        $entities = $user->getUserGroups();

        $result = $this->processSubEntities(
            $entities,
            $userGroups,
            $get,
            $add,
            $update,
            $delete
        );

        $this->resetIndexOfSubentites($entities);

        return $result;
    }
protected function processUserGroups(UserInterface $user, $userGroups)
    {
        $get = function($entity) {
            /* @var UserInterface $entity */
            return $entity->getId();
        };

        $delete = function($userGroup) use ($user) {
            $user->removeUserGroup($userGroup);
            $this->em->remove($userGroup);
        };

        $update = function($userGroup, $userGroupData) {
            return $this->updateUserGroup($userGroup, $userGroupData);
        };

        $add = function($userGroup) use ($user) {
            return $this->addUserGroup($user, $userGroup);
        };

        $entities = $user->getUserGroups();

        $result = $this->processSubEntities(
            $entities,
            $userGroups,
            $get,
            $add,
            $update,
            $delete
        );

        $this->resetIndexOfSubentites($entities);

        return $result;
    }
protected function processUserGroups ( UserInterface $ user , $ userGroups ) { $ get = function ( $ entity ) { /* @var UserInterface $entity */ return $ entity -> getId ( ) ; } ; $ delete = function ( $ userGroup ) use ( $ user ) { $ user -> removeUserGroup ( $ userGroup ) ; $ this -> em -> remove ( $ userGroup ) ; } ; $ update = function ( $ userGroup , $ userGroupData ) { return $ this -> updateUserGroup ( $ userGroup , $ userGroupData ) ; } ; $ add = function ( $ userGroup ) use ( $ user ) { return $ this -> addUserGroup ( $ user , $ userGroup ) ; } ; $ entities = $ user -> getUserGroups ( ) ; $ result = $ this -> processSubEntities ( $ entities , $ userGroups , $ get , $ add , $ update , $ delete ) ; $ this -> resetIndexOfSubentites ( $ entities ) ; return $ result ; }
Process all user groups from request.

@param UserInterface $user
@param $userGroups

@return bool True if the processing was successful, otherwise false
Process all user groups from request .