PHP Class Webiny\Component\Http\Response

Inheritance: use trait Webiny\Component\StdLib\StdObjectTrait
Mostrar archivo Open project: Webiny/Framework Class Usage Examples

Public Properties

Property Type Description
$httpStatuses An array of http status codes by RFC2616 standard or some other if noted by comment.

Public Methods

Method Description
__construct ( string $content = '', integer $statusCode = 200, array $headers = [] ) Constructs the Response object.
cacheControl ( ) : CacheControl Get access to cache control headers.
create ( string $content = '', integer $statusCode = 200, array $headers = [] ) : Response Static constructor.
getCharset ( ) : string Returns currently set response charset.
getContent ( ) : string Get response content.
getContentType ( ) : string Returns the currently set content type.
getHeaders ( ) : array Returns an array of current headers.
getStatusCode ( ) : integer Returns current status code.
send ( ) Sends both the headers and the content to the browser.
sendContent ( ) Sends the content to the browser.
sendHeaders ( ) Send the currently defined headers.
setAsNotModified ( ) Sets the response as not modified.
setCharset ( string $charset ) Set the response charset.
setContent ( string $content ) Set response content.
setContentType ( string $contentType ) Sets the Content-Type header value.
setHeader ( string $key, string $value ) Sets or adds a header.
setStatusCode ( integer $statusCode, string $message = '' ) Set HTTP response status code. The status code must be a valid HTTP status code, or an exception will be thrown.

Method Details

__construct() public method

Constructs the Response object.
public __construct ( string $content = '', integer $statusCode = 200, array $headers = [] )
$content string Content that will be attached to the response.
$statusCode integer HTTP status code that will be sent back to the user.
$headers array Additional headers that should be attached to the response.

cacheControl() public method

Get access to cache control headers.
public cacheControl ( ) : CacheControl
return Webiny\Component\Http\Response\CacheControl

create() public static method

Static constructor.
public static create ( string $content = '', integer $statusCode = 200, array $headers = [] ) : Response
$content string Content that will be attached to the response.
$statusCode integer HTTP status code that will be sent back to the user.
$headers array Additional headers that should be attached to the response.
return Response

getCharset() public method

Returns currently set response charset.
public getCharset ( ) : string
return string

getContent() public method

Get response content.
public getContent ( ) : string
return string

getContentType() public method

Returns the currently set content type.
public getContentType ( ) : string
return string

getHeaders() public method

Returns an array of current headers.
public getHeaders ( ) : array
return array

getStatusCode() public method

Returns current status code.
public getStatusCode ( ) : integer
return integer

send() public method

Sends both the headers and the content to the browser.
public send ( )

sendContent() public method

Sends the content to the browser.
public sendContent ( )

sendHeaders() public method

This also sends the cache control headers.
public sendHeaders ( )

setAsNotModified() public method

Sets the response as not modified.
public setAsNotModified ( )

setCharset() public method

Set the response charset.
public setCharset ( string $charset )
$charset string Charset name.

setContent() public method

Set response content.
public setContent ( string $content )
$content string Response content.

setContentType() public method

Sets the Content-Type header value.
public setContentType ( string $contentType )
$contentType string

setHeader() public method

Sets or adds a header.
public setHeader ( string $key, string $value )
$key string Header name.
$value string Header value.

setStatusCode() public method

Set HTTP response status code. The status code must be a valid HTTP status code, or an exception will be thrown.
public setStatusCode ( integer $statusCode, string $message = '' )
$statusCode integer Http status code.
$message string Http status message. If not set we will use the default message by RFC2616.

Property Details

$httpStatuses public_oe static_oe property

An array of http status codes by RFC2616 standard or some other if noted by comment.
public static $httpStatuses