Transform ApiResponse::exit() into dynamic method

This commit is contained in:
Philipp 2021-11-12 20:03:27 +01:00
parent 4309f814e0
commit ea0f41ecf0
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
13 changed files with 27 additions and 30 deletions

View file

@ -145,7 +145,7 @@ class ApiResponse
header(($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1') . ' ' . $code . ' ' . $description);
self::exit('status', ['status' => $error], $format);
DI::apiResponse()->exit('status', ['status' => $error], $format);
}
/**
@ -157,11 +157,11 @@ class ApiResponse
*
* @return void
*/
public static function exit(string $root_element, array $data, string $format = null)
public function exit(string $root_element, array $data, string $format = null)
{
$format = $format ?? 'json';
$return = DI::apiResponse()->formatData($root_element, $format, $data);
$return = $this->formatData($root_element, $format, $data);
switch ($format) {
case 'xml':