public function updateUser( $user, $fields = array() )
    {
        /** @var \eZ\Publish\API\Repository\Repository $repository */
        $repository = $this->getRepository();
        $contentService = $repository->getContentService();
        $userService = $repository->getUserService();

        $userUpdateStruct = $userService->newUserUpdateStruct();
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
        foreach ( $fields as $fieldName => $fieldValue )
        {
            switch ( $fieldName )
            {
                case 'password':
                    // TODO: throw, not impl.
                    break;
                case 'email':
                    // TODO: throw, not impl.
                    break;
                default:
                    $contentUpdateStruct->setField( $fieldName, $fieldValue, 'eng-GB' );
                    break;
            }
        }
        $userUpdateStruct->contentUpdateStruct = $contentUpdateStruct;

        $repository->sudo(
            function() use( $user, $userUpdateStruct, $userService )
            {
                $userService->updateUser( $user, $userUpdateStruct );
            }
        );
    }
public function updateUser( $user, $fields = array() )
    {
        /** @var \eZ\Publish\API\Repository\Repository $repository */
        $repository = $this->getRepository();
        $contentService = $repository->getContentService();
        $userService = $repository->getUserService();

        $userUpdateStruct = $userService->newUserUpdateStruct();
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
        foreach ( $fields as $fieldName => $fieldValue )
        {
            switch ( $fieldName )
            {
                case 'password':
                    // TODO: throw, not impl.
                    break;
                case 'email':
                    // TODO: throw, not impl.
                    break;
                default:
                    $contentUpdateStruct->setField( $fieldName, $fieldValue, 'eng-GB' );
                    break;
            }
        }
        $userUpdateStruct->contentUpdateStruct = $contentUpdateStruct;

        $repository->sudo(
            function() use( $user, $userUpdateStruct, $userService )
            {
                $userService->updateUser( $user, $userUpdateStruct );
            }
        );
    }
public function updateUser ( $ user , $ fields = array ( ) ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $ repository = $ this -> getRepository ( ) ; $ contentService = $ repository -> getContentService ( ) ; $ userService = $ repository -> getUserService ( ) ; $ userUpdateStruct = $ userService -> newUserUpdateStruct ( ) ; $ contentUpdateStruct = $ contentService -> newContentUpdateStruct ( ) ; foreach ( $ fields as $ fieldName => $ fieldValue ) { switch ( $ fieldName ) { case 'password' : // TODO: throw, not impl. break ; case 'email' : // TODO: throw, not impl. break ; default : $ contentUpdateStruct -> setField ( $ fieldName , $ fieldValue , 'eng-GB' ) ; break ; } } $ userUpdateStruct -> contentUpdateStruct = $ contentUpdateStruct ; $ repository -> sudo ( function ( ) use ( $ user , $ userUpdateStruct , $ userService ) { $ userService -> updateUser ( $ user , $ userUpdateStruct ) ; } ) ; }
Update user with given field and value

@param $user user to update
@param $fieldLabel name of the field to update
@param $fieldValue value of the field to update to
Update user with given field and value