понедельник, 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.

среда, 4 июля 2018 г.

Notice: undefined index id after changing MongoDB id to string

after using a php annotation @Mongo\Id(strategy="NONE") you can receive Notice: undefined index id PHP error, for this just run symfony cache:clear command.