0

I wanna throw an HTTP_NO_CONTENT, but symfony tells me that ClassNotFoundException: Attempted to load class "Codes" from namespace "FOS\Rest\Util". Do you need to "use" it from another namespace?

I actually did use FOS\RestBundle\Util\Codes; in my class.

My call looks like this

public function deleteAction($id)
{
  $em = $this->getDoctrine()->getManager();
  $player = $em->getRepository('xxx')->find($id);

  $em->remove($player);
  $em->flush();

  return $this->view(null, new HTTP_NO_CONTENT);
}

Why is it not possible to find that class?

Fabian
  • 1,806
  • 5
  • 25
  • 40

1 Answers1

2

new HTTP_NO_CONTENT doesn't make sens here! You've to use FOS\RestBundle\Util\Codes class,

use FOS\RestBundle\Util\Codes;

and point to the right status code as follow,

Codes::HTTP_NO_CONTENT // As HTTP_NO_CONTENT is defined as a constant
Ahmed Siouani
  • 13,701
  • 12
  • 61
  • 72