Response
in package
This is the Response class.
This class encapsulates the response information that will be delivered to the request, so the responses to each request had to be prepared through this class.
Tags
Table of Contents
TYPE_CSS | = 'css' | |
---|---|---|
TYPE_HTML | = 'html' | |
TYPE_JS | = 'js' | |
TYPE_JSON | = 'json' | |
TYPE_PDF | = 'pdf' | |
TYPE_XML | = 'xml' | |
addCacheHeaders() | This method sets the headers associated with the Cache Control. | : void |
addCommerceId() | This method adds the given commerceId name to the response. This is used by the response to add an specific header to the response informing about the commerceId. | : void |
addController() | This method adds the given controller name to the response. This is used by the response to add an specific header to the response informing about the controllers used by the request resolution. | : void |
addHeader() | This method adds a header to the response. | : void |
forbidden() | This method set forbidden response. | : void |
getHeaders() | This method returns the headers of the response. | : array<string|int, mixed> |
getInstance() | This method returns the instance of the Response. | : self |
getStructHeaders() | This method returns the headers of the response. | : array<string|int, mixed> |
getType() | This method returns the type of the response (@see Response Types) | : string |
output() | This method executes the return/output of the response to the current request. | : void |
outputJson() | : void | |
redirect() | This method redirects to the given url with the given status. | : void |
setType() | This method sets the type of the response. | : void |
Constants
TYPE_CSS
public
mixed
TYPE_CSS
= 'css'
TYPE_HTML
public
mixed
TYPE_HTML
= 'html'
TYPE_JS
public
mixed
TYPE_JS
= 'js'
TYPE_JSON
public
mixed
TYPE_JSON
= 'json'
TYPE_PDF
public
mixed
TYPE_PDF
= 'pdf'
TYPE_XML
public
mixed
TYPE_XML
= 'xml'
Methods
addCacheHeaders()
This method sets the headers associated with the Cache Control.
public
static addCacheHeaders([bool $isCacheable = true ]) : void
Parameters
- $isCacheable : bool = true
Return values
void —addCommerceId()
This method adds the given commerceId name to the response. This is used by the response to add an specific header to the response informing about the commerceId.
public
static addCommerceId(string $commerceId) : void
Parameters
- $commerceId : string
Return values
void —addController()
This method adds the given controller name to the response. This is used by the response to add an specific header to the response informing about the controllers used by the request resolution.
public
static addController(string $controller) : void
Parameters
- $controller : string
Return values
void —addHeader()
This method adds a header to the response.
public
static addHeader(string $header) : void
Parameters
- $header : string
-
example: 'Content-Type: application/json'
Return values
void —forbidden()
This method set forbidden response.
public
static forbidden() : void
Return values
void —getHeaders()
This method returns the headers of the response.
public
static getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —where each position is an string that contains one of the response headers.
getInstance()
This method returns the instance of the Response.
public
static getInstance() : self
Return values
self —getStructHeaders()
This method returns the headers of the response.
public
static getStructHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —where each position is an string that contains one of the response headers.
getType()
This method returns the type of the response (@see Response Types)
public
static getType() : string
Tags
Return values
string —output()
This method executes the return/output of the response to the current request.
public
static output(string $output) : void
Parameters
- $output : string
Return values
void —outputJson()
public
static outputJson(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Tags
Return values
void —redirect()
This method redirects to the given url with the given status.
public
static redirect(string $url[, int $status = 302 ][, bool $cacheRedirect = false ]) : void
Parameters
- $url : string
- $status : int = 302
- $cacheRedirect : bool = false
Return values
void —setType()
This method sets the type of the response.
public
static setType(string $type) : void
Parameters
- $type : string
-
to indicate the type of the response (@see Response Types)