понедельник, 30 июля 2018 г.

FOSRestBundle invalid form doesn't use ExceptionWrapper

If your FOSRestBundle response doesn't have normal type, (for example, as below):

{
    "form": {
        "children": {
            "currency": {},
            "limit": {
                "errors": [
                    "This value should be greater than or equal to 0."                ]
            },
            "": {},
            "name": {}
        }
    },
    "errors": []
},
As we see, there are no 'code' and 'message' keys, so FOSRestBundle type is wrong. To fix it, use
$view->getContext()->setAttribute('status_code', Response::HTTP_BAD_REQUEST);
for your $view object.

Комментариев нет:

Отправить комментарий