JsonHttpResponse
extends HttpResponse
in package
Table of Contents
Properties
- $body : string|null
- The HTML body of the response
- $cacheMaxAge : int|null
- Client cache max age in seconds
- $code : int|null
- The HTTP response code
- $contentLength : int|null
- $contentType : string|null
- $controllerOutput : string|null
- The output of the controller when running it
- $data : array<string|int, mixed>|JsonSerializable|stdClass|null
- The data of the JSON response
- $download : bool
- Is the file downloaded ? Or displayed ?
- $fileName : string|null
- The file name shared to the client
- $lastModifiedDate : DateTime|null
- Client cache max age in seconds
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Get this response as string
- collect() : void
- collectFrom() : void
- generateFromException() : JsonHttpResponse
- Generate HtmlResponse from Exception
- generateFromUserException() : JsonHttpResponse
- Generate HtmlResponse from UserException
- getBody() : string
- Get the body
- getCacheMaxAge() : int
- getCode() : int|null
- Get the code
- getContentLength() : int
- getContentType() : string|null
- getControllerOutput() : string|null
- Get the controller output
- getData() : array<string|int, mixed>|stdClass|JsonSerializable|null
- Get the data
- getFileName() : string
- getHttpDateFormat() : string
- getLastModifiedDate() : DateTime
- isDownload() : bool
- process() : void
- Process the response
- render() : JsonHttpResponse
- Render the given data
- returnData() : JsonHttpResponse
- Get a response with the given $data
- run() : bool
- Process response to client
- setBody() : HttpResponse
- Set the body
- setCacheMaxAge() : void
- setCode() : HttpResponse
- Set the code
- setContentLength() : void
- setContentType() : void
- setControllerOutput() : void
- Set the controller output
- setData() : JsonHttpResponse
- Set the data
- setDownload() : void
- setFileName() : void
- setLastModifiedDate() : $this
- getContentDisposition() : string
- Get content disposition header value
- sendHeaders() : void
Properties
$body
The HTML body of the response
protected
string|null
$body
= null
$cacheMaxAge
Client cache max age in seconds
protected
int|null
$cacheMaxAge
= null
$code
The HTTP response code
protected
int|null
$code
= null
$contentLength
protected
int|null
$contentLength
= null
The content length to send to client
$contentType
protected
string|null
$contentType
= null
The content type to send to client
$controllerOutput
The output of the controller when running it
protected
string|null
$controllerOutput
= null
$data
The data of the JSON response
protected
array<string|int, mixed>|JsonSerializable|stdClass|null
$data
$download
Is the file downloaded ? Or displayed ?
protected
bool
$download
= false
$fileName
The file name shared to the client
protected
string|null
$fileName
= null
$lastModifiedDate
Client cache max age in seconds
protected
DateTime|null
$lastModifiedDate
= null
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed>|JsonSerializable|stdClass|null $data = null ][, bool $download = false ][, string|null $fileName = null ]) : mixed
Parameters
- $data : array<string|int, mixed>|JsonSerializable|stdClass|null = null
- $download : bool = false
- $fileName : string|null = null
__toString()
Get this response as string
public
__toString() : string
Return values
stringcollect()
public
collect(string $textCode[, mixed $other = null ][, string $domain = 'global' ][, string|null $description = null ]) : void
Parameters
- $textCode : string
- $other : mixed = null
- $domain : string = 'global'
- $description : string|null = null
collectFrom()
public
collectFrom(string $layout[, array<string|int, mixed> $values = [] ]) : void
Parameters
- $layout : string
- $values : array<string|int, mixed> = []
generateFromException()
Generate HtmlResponse from Exception
public
static generateFromException(Exception $exception[, array<string|int, mixed> $values = [] ]) : JsonHttpResponse
Parameters
- $exception : Exception
- $values : array<string|int, mixed> = []
Return values
JsonHttpResponsegenerateFromUserException()
Generate HtmlResponse from UserException
public
static generateFromUserException(UserException $exception[, array<string|int, mixed> $values = [] ]) : JsonHttpResponse
Parameters
- $exception : UserException
- $values : array<string|int, mixed> = []
Return values
JsonHttpResponsegetBody()
Get the body
public
getBody() : string
Return values
stringgetCacheMaxAge()
public
getCacheMaxAge() : int
Return values
intgetCode()
Get the code
public
getCode() : int|null
Return values
int|nullgetContentLength()
public
getContentLength() : int
Return values
intgetContentType()
public
getContentType() : string|null
Return values
string|nullgetControllerOutput()
Get the controller output
public
getControllerOutput() : string|null
Return values
string|nullgetData()
Get the data
public
getData() : array<string|int, mixed>|stdClass|JsonSerializable|null
Return values
array<string|int, mixed>|stdClass|JsonSerializable|nullgetFileName()
public
getFileName() : string
Return values
stringgetHttpDateFormat()
public
getHttpDateFormat() : string
Return values
stringgetLastModifiedDate()
public
getLastModifiedDate() : DateTime
Return values
DateTimeisDownload()
public
isDownload() : bool
Return values
boolprocess()
Process the response
public
process() : void
render()
Render the given data
public
static render(string $textCode[, mixed|null $other = null ][, string|null $domain = null ][, string|null $description = null ]) : JsonHttpResponse
Parameters
- $textCode : string
- $other : mixed|null = null
- $domain : string|null = null
- $description : string|null = null
Tags
Return values
JsonHttpResponsereturnData()
Get a response with the given $data
public
static returnData(mixed $data) : JsonHttpResponse
Parameters
- $data : mixed
Tags
Return values
JsonHttpResponserun()
Process response to client
public
run() : bool
Tags
Return values
boolsetBody()
Set the body
public
setBody(string|null $body) : HttpResponse
Parameters
- $body : string|null
Return values
HttpResponsesetCacheMaxAge()
public
setCacheMaxAge(int $cacheMaxAge) : void
Parameters
- $cacheMaxAge : int
setCode()
Set the code
public
setCode(int $code) : HttpResponse
Parameters
- $code : int
Return values
HttpResponsesetContentLength()
public
setContentLength(int $contentLength) : void
Parameters
- $contentLength : int
setContentType()
public
setContentType(string $contentType) : void
Parameters
- $contentType : string
setControllerOutput()
Set the controller output
public
setControllerOutput(string $controllerOutput) : void
Parameters
- $controllerOutput : string
setData()
Set the data
public
setData(array<string|int, mixed>|JsonSerializable|stdClass|null $data) : JsonHttpResponse
Parameters
- $data : array<string|int, mixed>|JsonSerializable|stdClass|null
Return values
JsonHttpResponsesetDownload()
public
setDownload(bool $download) : void
Parameters
- $download : bool
setFileName()
public
setFileName(string $fileName) : void
Parameters
- $fileName : string
setLastModifiedDate()
public
setLastModifiedDate(DateTime|int $lastModifiedDate) : $this
Parameters
- $lastModifiedDate : DateTime|int
-
DateTime or timestamp
Return values
$thisgetContentDisposition()
Get content disposition header value
protected
getContentDisposition() : string
Return values
stringsendHeaders()
protected
sendHeaders() : void