Symfony2 FOSRestBundle:对于HTTP\u NO\u内容之类的代码,应该包含哪个类

Symfony2 FOSRestBundle:对于HTTP\u NO\u内容之类的代码,应该包含哪个类,symfony,fosrestbundle,Symfony,Fosrestbundle,我想抛出一个HTTP\u NO\u内容,但symfony告诉我ClassNotFoundException:试图从名称空间“FOS\Rest\Util”加载类“code”。您需要从另一个命名空间“使用”它吗? 我确实使用了FOS\RestBundle\Util\code在我的课堂上 我的电话是这样的 public function deleteAction($id) { $em = $this->getDoctrine()->getManager(); $player = $

我想抛出一个HTTP\u NO\u内容,但symfony告诉我
ClassNotFoundException:试图从名称空间“FOS\Rest\Util”加载类“code”。您需要从另一个命名空间“使用”它吗?

我确实使用了FOS\RestBundle\Util\code在我的课堂上

我的电话是这样的

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);
}

为什么找不到那个类?

新的HTTP\u NO\u内容在这里没有意义!您必须使用
FOS\RestBundle\Util\Codes
class

use FOS\RestBundle\Util\Codes;
并指向正确的状态代码,如下所示

Codes::HTTP_NO_CONTENT // As HTTP_NO_CONTENT is defined as a constant