public function deleteAction($id)
    {
        if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
            throw new InsufficientAuthenticationException('You must be authenticated to delete users');
        }

        if (intval($id) === $this->getUser()->getId()) {
            throw new InsufficientAuthenticationException('You can remove the user of your current session.');
        }

        $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('DELETE', $user)) {
            throw new InsufficientAuthenticationException(sprintf('You are not authorized to delete user with id %s', $id));
        }

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

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

        if (intval($id) === $this->getUser()->getId()) {
            throw new InsufficientAuthenticationException('You can remove the user of your current session.');
        }

        $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('DELETE', $user)) {
            throw new InsufficientAuthenticationException(sprintf('You are not authorized to delete user with id %s', $id));
        }

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

        return new Response("", 204);
    }
public function deleteAction ( $ id ) { if ( ! $ this -> isGranted ( 'IS_AUTHENTICATED_FULLY' ) ) { throw new InsufficientAuthenticationException ( 'You must be authenticated to delete users' ) ; } if ( intval ( $ id ) === $ this -> getUser ( ) -> getId ( ) ) { throw new InsufficientAuthenticationException ( 'You can remove the user of your current session.' ) ; } $ 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 ( 'DELETE' , $ user ) ) { throw new InsufficientAuthenticationException ( sprintf ( 'You are not authorized to delete user with id %s' , $ id ) ) ; } $ this -> getEntityManager ( ) -> remove ( $ user ) ; $ this -> getEntityManager ( ) -> flush ( ) ; return new Response ( "" , 204 ) ; }
DELETE User.

@param int $id User ID
DELETE User .