ResponseMaker
Response Maker Trait
Stores attributes the can be used to prepare a response from the server.
trait System\Traits\ResponseMaker
Properties
protected
$responseHeaderBag
:
Symfony\Component\HttpFoundation\ResponseHeaderBag
= null
protected
$responseOverride
:
mixed
= null
Override the standard controller response.
protected
$statusCode
:
int
= 200
Response status code
Methods
public getResponseHeaders () : Symfony\Component\HttpFoundation\ResponseHeaderBag | null
Get the header response bag
Returns
Symfony\Component\HttpFoundation\ResponseHeaderBag | null
public getStatusCode () : int
Returns the status code for the current web response.
Returns
int
Status code
public makeResponse (mixed $contents) : mixed
Prepares a response that considers overrides and custom responses.
Parameters
Property | Type | Description |
---|---|---|
$contents | mixed |
mixed
|
Returns
mixed
public setResponse (mixed $response) : $this
Sets the response for the current page request cycle, this value takes priority over the standard response prepared by the controller.
Parameters
Property | Type | Description |
---|---|---|
$response | mixed |
mixed
Response object or string |
Returns
$this
public setResponseCookie (Symfony\Component\HttpFoundation\Cookie | mixed $cookie) : $this
Add a cookie to the response.
Parameters
Property | Type | Description |
---|---|---|
$cookie | Symfony\Component\HttpFoundation\Cookie | mixed |
Symfony\Component\HttpFoundation\Cookie | mixed
|
Returns
$this
public
setResponseHeader (string $key, array | string $values, boolean $replace = true
)
: $this
Set a header on the Response.
Parameters
Property | Type | Description |
---|---|---|
$key | string |
string
|
$values | array | string |
array | string
|
$replace | boolean |
boolean
|
Returns
$this
public setStatusCode (int $code) : $this
Sets the status code for the current web response.
Parameters
Property | Type | Description |
---|---|---|
$code | int |
int
Status code |
Returns
$this
Copyright © 2023 Winter CMS