* Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
* of $st and an optional text <message> of $message and terminates the current process.
*
- * @param $st
+ * @param mixed $status
* @param string $message
* @throws \Exception
+ * @deprecated since 2023.09 Use BaseModule->httpExit() instead
*/
- public static function xmlExit($st, $message = '')
+ public static function xmlExit($status, string $message = '')
{
- $result = ['status' => $st];
+ $result = ['status' => $status];
if ($message != '') {
$result['message'] = $message;
}
- if ($st) {
- Logger::notice('xml_status returning non_zero: ' . $st . " message=" . $message);
+ if ($status) {
+ Logger::notice('xml_status returning non_zero: ' . $status . " message=" . $message);
}
- DI::apiResponse()->setType(Response::TYPE_XML);
- DI::apiResponse()->addContent(XML::fromArray(['result' => $result]));
- self::echoResponse(DI::apiResponse()->generate());
-
- self::exit();
+ self::httpExit(XML::fromArray(['result' => $result]), Response::TYPE_XML);
}
/**
self::exit();
}
+ /**
+ * @deprecated since 2023.09 Use BaseModule->jsonError instead
+ */
public static function jsonError($httpCode, $content, $content_type = 'application/json')
{
if ($httpCode >= 400) {
* @param mixed $content The input content
* @param string $content_type Type of the input (Default: 'application/json')
* @param integer $options JSON options
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
+ * @deprecated since 2023.09 Use BaseModule->jsonExit instead
*/
- public static function jsonExit($content, $content_type = 'application/json', int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) {
- DI::apiResponse()->setType(Response::TYPE_JSON, $content_type);
- DI::apiResponse()->addContent(json_encode($content, $options));
- self::echoResponse(DI::apiResponse()->generate());
-
- self::exit();
+ public static function jsonExit($content, string $content_type = 'application/json', int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
+ {
+ self::httpExit(json_encode($content, $options), Response::TYPE_JSON, $content_type);
}
/**