config.yml:
fos_rest:
param_fetcher_listener: true
body_listener: true
format_listener:
default_priorities: [json, xml]
view:
view_response_listener: 'force'
sensio_framework_extra:
view: { annotations: false }
router: { annotations: true }
annotated controller:
/**
* @Rest\View(statusCode=204)
* @param \Symfony\Component\HttpFoundation\Request $request
*/
public function signUpAction(Request $request)
{
return $this->get('%%%.response_generator')->generateResponse(array('test'), true, 'test');
// returns a simple Object with some public properties
}
.json
如果我使用它返回的格式访问路由:
{"status":1,"message":"test","data":["test"]}
但它不会将状态代码更改为注释中的状态代码。
同样没有指定格式,它不会回退到默认.json
格式,它仍然会搜索模板。