data instanceof ActionStatus) { /** @var ActionStatus $status */ $status = $this->data; $this->data = $status->toRawArray(); if (isset($status->code) && $status->code) { $this->statusCode = $status->code; } else if (isset($status->status)) { $this->statusCode = $status->status ? 200 : 400; } } if (self::FORMAT_JSON === $this->format) { if ($this->getStatusCode() >= 500) { $yiiData = $this->data; $apiData = [ 'status' => false, 'message' => (isset($yiiData['message'])) ? $yiiData['message'] : $this->statusText, ]; if (isset($yiiData['name']) && isset($yiiData['message'])) { $apiData['errors'] = [ $yiiData['name'] => ((isset($yiiData['type'])) ? $yiiData['type'] . ': ' : '') . $yiiData['message'], ]; } $this->data = $apiData; } } parent::prepare(); } }