response->format = \yii\web\Response::FORMAT_JSON; return [ 'return' => $responseType, 'alert' => [ 'type' => self::getAlertClass($responseType), 'message' => $message ] ]; } private static function getAlertClass(string $responseType) { $class = ''; if($responseType == self::RESPONSE_TYPE_SUCCESS) { $class = 'success'; } elseif($responseType == self::RESPONSE_TYPE_ERROR) { $class = 'danger'; } return $class; } }