Код: Выделить всё
'response' => [
'format' => yii\web\Response::FORMAT_JSON,
Код: Выделить всё
'response' => [
......
'on beforeSend' => function ($event) {
$response = $event->sender;
if ($response->data !== null && !empty(Yii::$app->request->get('suppress_response_code'))) {
$response->data = [
'success' => $response->isSuccessful,
'data' => $response->data,
];
$response->statusCode = 200;
}
},
Код: Выделить всё
public function behaviors() {
$behaviors = parent::behaviors();
unset($behaviors['contentNegotiator']['formats']['application/xml']);
return $behaviors;
}
Ну и собственно непонятно, почему не работает ['response']['on beforeSend']. Если сувать туда всякие вардампы, то видно что код срабатывает. Но в выдаче (тестирую 404) стандартный ответ
Код: Выделить всё
{"name":"Not Found","message":"Page not found.","code":0,"status":404,"type":"yii\\web\\NotFoundHttpException"}