The main façade of the Jet\RESTServer subsystem.

Overview of methods

Method Meaning of
public static getBackend(
) : RESTServer_Backend
Returns the backend instance. If you did not specify a custom backend using the setBackend method, then an instance of Jet\RESTServer_Backend_Default is used.
public static setBackend(
RESTServer_Backend $backend
) : void
Sets an optional backend. Of course, the method must be used before the RESTServer can be used. Thus, for example, the base initializer.
public static init(
) : void
Initialization of the REST server itself. For example, it does things like debugging switches to JSON mode, sets up error pages, or performs other operations (if you need to).
public static getRequestMethod(
) : string
Specifies the method of the request (whether it is post, get, put, delete, ...)
public static getRequestData(
) : array
Returns the data from the request body (e.g. during a post request) from JSON converted to the associated array.

Routinely checks if the data exists and if it is JSON.
public static getHttpRequestHeader(
string $header,
string $default_value=''
) : string
Returns the value of the specified http header of the request, or the default value if this header is missing from the request.
public static responseData(
mixed $data
) : void
General sending of arbitrary data - e.g. data of a certain entity (for example, an article) after a successful get request.
public static responseOK(
string $message=''
) : void
Simple answer OK - only with a certain message, but no additional data.
public static handleNotAuthorized(
) : void
General answer: you are not authorised to do so.
public static responseError(
string|int $code,
mixed $data=null
) : void
A general error response with some code and optionally error data (specifying the nature of the error).
public static responseValidationError(
array $errors
) : void
Input data validation error.
The error messages in the field must be serializable to JSON.
This can be for example an instance of Jet\Form_ValidationError.
public static responseUnknownItem(
string|array $id
) : void
General answer unknown item/unknown items. The $id parameter specifies which item is unknown / which items are unknown.
public static responseBadRequest(
) : void
General answer wrong request.
public static handleDataPagination(
DataModel_Fetch_Instances $data
) : Data_Paginator
Based on the get parameters (for example), it will process the pagination of the data list and return the set pager.
public static handleOrderBy(
DataModel_Fetch_Instances $data,
array $sort_items_map
) : DataModel_Fetch_Instances
Based on the get parameters (for example) it serves the sorting of the list of data. The $sort_items_map parameter is an associated array that specifies which parameter (e.g. get) will sort which data column. For example: public function list_Action(): void
'title'     => 'article_localized.title',
'date_time' => 'article.date_time'
Previous chapter
Next chapter