PHP Class lithium\action\Response

The Response object is responsible for writing its body content to output, and writing any headers to the browser.
See also: lithium\action\Dispatcher
See also: lithium\action\Controller
Inheritance: extends lithium\net\http\Response
Afficher le fichier Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Свойство Type Description
$_autoConfig array Auto configuration properties.
$_classes array Classes used by Response.

Méthodes publiques

Méthode Description
__construct ( array $config = [] ) : void Constructor. Adds config values to the public properties when a new object is created.
__toString ( ) : string Casts the Response object to a string. This doesn't actually return a string, but does a direct render and returns an empty string.
cache ( mixed $expires ) : void Controls how or whether the client browser and web proxies should cache this response.
headers ( string | array $key = null, mixed $value = null, boolean $replace = true ) : mixed Expands on \net\http\Message::headers() with some magic conversions for shorthand headers.
render ( ) : void Render a response by writing headers and output. Output is echoed in chunks because of an issue where echo time increases exponentially on long message bodies.
type ( string $type = null ) : string Sets/Gets the content type. If 'type' is null, the method will attempt to determine the type from the params, then from the environment setting

Méthodes protégées

Méthode Description
_init ( ) : void Sets the Location header using $config['location'] and $config['request'] passed in through the constructor if provided.
_writeHeaders ( string | array $headers, integer $code = null ) : void Writes raw headers to output.

Method Details

__construct() public méthode

Config options also include default values for Response::body() when called from Response::render().
See also: lithium\net\http\Message::body()
See also: lithium\net\http\Response::__construct()
See also: lithium\net\http\Message::__construct()
See also: lithium\net\Message::__construct()
public __construct ( array $config = [] ) : void
$config array The available configuration options are the following. Further options are inherited from the parent classes. - `'buffer'` _integer_: Defaults to `null` - `'decode'` _boolean_: Defaults to `null`. - `'location'` _array|string|null_: Defaults to `null`. - `'request'` _object_: Defaults to `null`.
Résultat void

__toString() public méthode

Casts the Response object to a string. This doesn't actually return a string, but does a direct render and returns an empty string.
public __toString ( ) : string
Résultat string Just an empty string to satify requirements of this magic method.

_init() protected méthode

Sets the Location header using $config['location'] and $config['request'] passed in through the constructor if provided.
protected _init ( ) : void
Résultat void

_writeHeaders() protected méthode

Writes raw headers to output.
protected _writeHeaders ( string | array $headers, integer $code = null ) : void
$headers string | array Either a raw header string, or an array of header strings. Use an array if a single header must be written multiple times with different values. Otherwise, additional values for duplicate headers will overwrite previous values.
$code integer Optional. If present, forces a specific HTTP response code. Used primarily in conjunction with the 'Location' header.
Résultat void

cache() public méthode

Controls how or whether the client browser and web proxies should cache this response.
public cache ( mixed $expires ) : void
$expires mixed This can be a Unix timestamp indicating when the page expires, or a string indicating the relative time offset that a page should expire, i.e. `"+5 hours". Finally, `$expires` can be set to `false` to completely disable browser or proxy caching.
Résultat void

headers() public méthode

Expands on \net\http\Message::headers() with some magic conversions for shorthand headers.
Deprecation: This method will be removed in a future version. Note that the parent `header()` wil continue to exist.
public headers ( string | array $key = null, mixed $value = null, boolean $replace = true ) : mixed
$key string | array
$value mixed
$replace boolean
Résultat mixed

render() public méthode

Reponses which have a Location header set are indicating a redirect, will get their status code automatically adjusted to 302 (Found/Moved Temporarily) in case the status code before was 200 (OK). This is to allow easy redirects by setting just the Location header and is assumed to be the original intent of the user. On responses with status codes 204 (No Content) and 302 (Found) a message body - even if one is set - will never be send. These status codes either don't have a message body as per their nature or they are ignored and can thus be omitted for performance reasons.
public render ( ) : void
Résultat void

type() public méthode

Sets/Gets the content type. If 'type' is null, the method will attempt to determine the type from the params, then from the environment setting
public type ( string $type = null ) : string
$type string a full content type i.e. `'application/json'` or simple name `'json'`
Résultat string A simple content type name, i.e. `'html'`, `'xml'`, `'json'`, etc., depending on the content type of the request.

Property Details

$_autoConfig protected_oe property

Auto configuration properties.
protected array $_autoConfig
Résultat array

$_classes protected_oe property

Classes used by Response.
protected array $_classes
Résultat array