我想抛出一个HTTP_NO_CONTENT,但是symfony告诉我ClassNotFoundException: Attempted to load class "Codes" from namespace "FOS\Rest\Util". Do you need to "use" it from another namespace?
我实际上在班上做了use FOS\RestBundle\Util\Codes;
。
我的电话看起来像这样
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);
}
为什么找不到那个班级?
答案 0 :(得分:2)
new HTTP_NO_CONTENT
在这里没有感觉!你必须使用FOS\RestBundle\Util\Codes
类,
use FOS\RestBundle\Util\Codes;
并指向正确的状态代码,如下所示,
Codes::HTTP_NO_CONTENT // As HTTP_NO_CONTENT is defined as a constant