"init" removed, moved error function

This commit is contained in:
Michael 2021-11-09 22:59:58 +00:00
parent 28a28517e5
commit bbc4fe851b
3 changed files with 37 additions and 48 deletions

View file

@ -53,10 +53,6 @@ class BaseApi extends BaseModule
*/
protected static $request = [];
public static function init(array $parameters = [])
{
}
public static function delete(array $parameters = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
@ -331,6 +327,28 @@ class BaseApi extends BaseModule
return api_get_user($contact_id);
}
/**
* Exit with error code
*
* @param int $code
* @param string $description
* @param string $message
* @param string|null $format
* @return void
*/
public static function error(int $code, string $description, string $message, string $format = null)
{
$error = [
'error' => $message ?: $description,
'code' => $code . ' ' . $description,
'request' => DI::args()->getQueryString()
];
header($_SERVER["SERVER_PROTOCOL"] . ' ' . $code . ' ' . $description);
self::exit('status', ['status' => $error], $format);
}
/**
* Outputs formatted data according to the data type and then exits the execution.
*