Documentation

CResponse
in package

Manages the response to user requests (manages views).

Tags

Table of Contents

HTTP_STATUS_BAD_REQUEST  = 400
HTTP_STATUS_CREATED  = 201
HTTP_STATUS_FORBIDDEN  = 403
HTTP_STATUS_INTERNAL_SERVER_ERROR  = 500
HTTP_STATUS_METHOD_NOT_ACCEPTABLE  = 406
HTTP_STATUS_METHOD_NOT_ALLOWED  = 405
HTTP_STATUS_NOT_FOUND  = 404
HTTP_STATUS_NOT_MODIFIED  = 304
HTTP_STATUS_OK  = 200
HTTP_STATUS_UNAUTHORIZED  = 401
HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE  = 415
$format  : string
$message_error  : string
$status_code  : int
__construct()  : mixed
__construct
error()  : string
Method error
getMessageError()  : string
Get the message error
getStatusCode()  : int
Get the HTML status code
output()  : string
Method output
setMessageError()  : void
Set the message error
setStatusCode()  : void
Set the HTML status code
asDEBUG()  : string
Encode all data in Text format (for debug)
asJSON()  : string
Encode all data in JSON format
asPLAIN()  : string
Encode all data in CSV/Plain Text format
asXML()  : string
Encode all data in XML format
setDataHeaders()  : void

Constants

HTTP_STATUS_BAD_REQUEST

public mixed HTTP_STATUS_BAD_REQUEST = 400
Tags

HTTP_STATUS_INTERNAL_SERVER_ERROR

public mixed HTTP_STATUS_INTERNAL_SERVER_ERROR = 500
Tags

HTTP_STATUS_METHOD_NOT_ACCEPTABLE

public mixed HTTP_STATUS_METHOD_NOT_ACCEPTABLE = 406
Tags

HTTP_STATUS_METHOD_NOT_ALLOWED

public mixed HTTP_STATUS_METHOD_NOT_ALLOWED = 405
Tags

HTTP_STATUS_NOT_MODIFIED

public mixed HTTP_STATUS_NOT_MODIFIED = 304
Tags

HTTP_STATUS_UNAUTHORIZED

public mixed HTTP_STATUS_UNAUTHORIZED = 401
Tags

HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE

public mixed HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415
Tags

Properties

$status_code

protected int $status_code = \dressapi\core\response\CResponse::HTTP_STATUS_OK
Tags

Methods

__construct()

__construct

public __construct() : mixed
Tags
Return values
mixed

error()

Method error

public error(int $code, string $message) : string

Return an error message

Parameters
$code : int
$message : string

messaggio da inviare

Tags
Return values
string

with error

getMessageError()

Get the message error

public getMessageError() : string
Tags
Return values
string

the message error

getStatusCode()

Get the HTML status code

public getStatusCode() : int
Tags
Return values
int

the status code

output()

Method output

public output(mixed $result) : string

Return the data results in the required format

Parameters
$result : mixed

data to tranform

Tags
Return values
string

all data results

setMessageError()

Set the message error

public setMessageError([string $message_error = '' ]) : void
Parameters
$message_error : string = ''

the message error

Tags
Return values
void

setStatusCode()

Set the HTML status code

public setStatusCode(int $status_code) : void
Parameters
$status_code : int
Tags
Return values
void

asDEBUG()

Encode all data in Text format (for debug)

protected asDEBUG(array<string|int, array|string>|object|null $data) : string
Parameters
$data : array<string|int, array|string>|object|null

array or object to send to client

Tags
Return values
string

data transformed into text format (for debugging)

asJSON()

Encode all data in JSON format

protected asJSON(array<string|int, array|string>|object|null $data) : string
Parameters
$data : array<string|int, array|string>|object|null

array or object to send to client

Tags
Return values
string

data transformed into JSON format

asPLAIN()

Encode all data in CSV/Plain Text format

protected asPLAIN(array<string|int, array|string>|object|null $data) : string
Parameters
$data : array<string|int, array|string>|object|null

array or object to send to client

Tags
Return values
string

data transformed into text format

asXML()

Encode all data in XML format

protected asXML(array<string|int, mixed> $data[, bool $full = true ]) : string
Parameters
$data : array<string|int, mixed>

array or object to send to client

$full : bool = true

if true, it also exposes empty data

Tags
Return values
string

transforms the data into a string containing XML format

setDataHeaders()

protected setDataHeaders() : void
Tags
Return values
void

        

Search results