public function putAction($id, Request $request)
    {
        if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
            throw new InsufficientAuthenticationException('You must be authenticated to view users');
        }

        $user = $this->getEntityManager()->find(get_class($this->getUser()), $id);

        if (!$user) {
            return $this->create404Response(sprintf('User not found with id %d', $id));
        }

        if (!$this->isGranted('EDIT', $user)) {
            throw new InsufficientAuthenticationException(sprintf('You are not authorized to view user with id %s', $id));
        }

        $user = $this->deserializeEntity($request->request->all(), $user);

        if ($request->request->has('password')) {
            $encoderFactory = $this->getContainer()->get('security.context')->getEncoderFactory();
            $password = $request->request->get('password', '');

            if ($encoderFactory && $encoder = $encoderFactory->getEncoder($user)) {
                $password = $encoder->encodePassword($password, '');
            }

            $user->setPassword($password);
        }

        $this->getEntityManager()->persist($user);
        $this->getEntityManager()->flush($user);

        return new Response("", 204);
    }
public function putAction($id, Request $request)
    {
        if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
            throw new InsufficientAuthenticationException('You must be authenticated to view users');
        }

        $user = $this->getEntityManager()->find(get_class($this->getUser()), $id);

        if (!$user) {
            return $this->create404Response(sprintf('User not found with id %d', $id));
        }

        if (!$this->isGranted('EDIT', $user)) {
            throw new InsufficientAuthenticationException(sprintf('You are not authorized to view user with id %s', $id));
        }

        $user = $this->deserializeEntity($request->request->all(), $user);

        if ($request->request->has('password')) {
            $encoderFactory = $this->getContainer()->get('security.context')->getEncoderFactory();
            $password = $request->request->get('password', '');

            if ($encoderFactory && $encoder = $encoderFactory->getEncoder($user)) {
                $password = $encoder->encodePassword($password, '');
            }

            $user->setPassword($password);
        }

        $this->getEntityManager()->persist($user);
        $this->getEntityManager()->flush($user);

        return new Response("", 204);
    }
public function putAction ( $ id , Request $ request ) { if ( ! $ this -> isGranted ( 'IS_AUTHENTICATED_FULLY' ) ) { throw new InsufficientAuthenticationException ( 'You must be authenticated to view users' ) ; } $ user = $ this -> getEntityManager ( ) -> find ( get_class ( $ this -> getUser ( ) ) , $ id ) ; if ( ! $ user ) { return $ this -> create404Response ( sprintf ( 'User not found with id %d' , $ id ) ) ; } if ( ! $ this -> isGranted ( 'EDIT' , $ user ) ) { throw new InsufficientAuthenticationException ( sprintf ( 'You are not authorized to view user with id %s' , $ id ) ) ; } $ user = $ this -> deserializeEntity ( $ request -> request -> all ( ) , $ user ) ; if ( $ request -> request -> has ( 'password' ) ) { $ encoderFactory = $ this -> getContainer ( ) -> get ( 'security.context' ) -> getEncoderFactory ( ) ; $ password = $ request -> request -> get ( 'password' , '' ) ; if ( $ encoderFactory && $ encoder = $ encoderFactory -> getEncoder ( $ user ) ) { $ password = $ encoder -> encodePassword ( $ password , '' ) ; } $ user -> setPassword ( $ password ) ; } $ this -> getEntityManager ( ) -> persist ( $ user ) ; $ this -> getEntityManager ( ) -> flush ( $ user ) ; return new Response ( "" , 204 ) ; }
UPDATE User.

@Rest\RequestParam(name = "login", requirements = {
@Assert\NotBlank(message="Login is required"),
@Assert\Length(min=6, minMessage="Minimum length of the login is 6 characters")
})
@Rest\RequestParam(name = "email", requirements = {
@Assert\NotBlank(message="Email not provided"),
@Assert\Email(checkMX=true, message="Email invalid")
})

@param int $id User ID
UPDATE User .