X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FSystem.php;h=197e7b2ae6acd43af9785bf490bf4531e2e08b87;hb=5704a433f00887b35fe866af6b161b096b27f9d9;hp=48a4ce614168ad0eadf3c1a0ad493ce12b12a157;hpb=e424b7bacbd18af53720bb6beaf876e7351f5099;p=friendica.git diff --git a/src/Core/System.php b/src/Core/System.php index 48a4ce6141..197e7b2ae6 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -311,27 +311,24 @@ class System * Outputs a basic dfrn XML status structure to STDOUT, with a variable * of $st and an optional text 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); } /** @@ -373,6 +370,9 @@ class System self::exit(); } + /** + * @deprecated since 2023.09 Use BaseModule->jsonError instead + */ public static function jsonError($httpCode, $content, $content_type = 'application/json') { if ($httpCode >= 400) { @@ -392,14 +392,12 @@ class System * @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); } /**