/** * Get the response with the status code from the payload. * * @param ResponseInterface $response * @param PayloadInterface $payload * * @return ResponseInterface */ private function status(ResponseInterface $response, PayloadInterface $payload) { $status = $payload->getStatus(); $code = $this->http_status->getStatusCode($status); return $response->withStatus($code); }
/** * Sends fail response * @param $data * @author Oluwarotimi Akintewe <*****@*****.**> * @author Adegoke Obasa <*****@*****.**> * @param int $httpStatusCode * @return array */ public function sendFailResponse($data, $httpStatusCode = 500) { \Yii::$app->response->format = Response::FORMAT_JSON; \Yii::$app->response->setStatusCode($httpStatusCode, $this->httpStatuses->getReasonPhrase($httpStatusCode)); return ['status' => 'fail', 'data' => $data]; }