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

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

        $update = function($userRole, $userRoleData) {
            return $this->updateUserRole($userRole, $userRoleData);
        };

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

        $entities = $user->getUserRoles();

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

        $this->resetIndexOfSubentites($entities);

        return $result;
    }
public function processUserRoles(UserInterface $user, $userRoles)
    {
        $get = function($entity) {
            /* @var UserInterface $entity */
            return $entity->getId();
        };

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

        $update = function($userRole, $userRoleData) {
            return $this->updateUserRole($userRole, $userRoleData);
        };

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

        $entities = $user->getUserRoles();

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

        $this->resetIndexOfSubentites($entities);

        return $result;
    }
public function processUserRoles ( UserInterface $ user , $ userRoles ) { $ get = function ( $ entity ) { /* @var UserInterface $entity */ return $ entity -> getId ( ) ; } ; $ delete = function ( $ userRole ) use ( $ user ) { $ user -> removeUserRole ( $ userRole ) ; $ this -> em -> remove ( $ userRole ) ; } ; $ update = function ( $ userRole , $ userRoleData ) { return $ this -> updateUserRole ( $ userRole , $ userRoleData ) ; } ; $ add = function ( $ userRole ) use ( $ user ) { return $ this -> addUserRole ( $ user , $ userRole ) ; } ; $ entities = $ user -> getUserRoles ( ) ; $ result = $ this -> processSubEntities ( $ entities , $ userRoles , $ get , $ add , $ update , $ delete ) ; $ this -> resetIndexOfSubentites ( $ entities ) ; return $ result ; }
Process all user roles from request.

@param UserInterface $user
@param array $userRoles

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