PHP Класс lithium\action\Response

The Response object is responsible for writing its body content to output, and writing any headers to the browser.
См. также: lithium\action\Dispatcher
См. также: lithium\action\Controller
Наследование: extends lithium\net\http\Response
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_autoConfig array Auto configuration properties.
$_classes array Classes used by Response.

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
_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.

Описание методов

__construct() публичный Метод

Config options also include default values for Response::body() when called from Response::render().
См. также: lithium\net\http\Message::body()
См. также: lithium\net\http\Response::__construct()
См. также: lithium\net\http\Message::__construct()
См. также: 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`.
Результат void

__toString() публичный Метод

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
Результат string Just an empty string to satify requirements of this magic method.

_init() защищенный Метод

Sets the Location header using $config['location'] and $config['request'] passed in through the constructor if provided.
protected _init ( ) : void
Результат void

_writeHeaders() защищенный Метод

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.
Результат void

cache() публичный Метод

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.
Результат void

headers() публичный Метод

Expands on \net\http\Message::headers() with some magic conversions for shorthand headers.
Устаревший: 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
Результат mixed

render() публичный Метод

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
Результат void

type() публичный Метод

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'`
Результат string A simple content type name, i.e. `'html'`, `'xml'`, `'json'`, etc., depending on the content type of the request.

Описание свойств

$_autoConfig защищенное свойство

Auto configuration properties.
protected array $_autoConfig
Результат array

$_classes защищенное свойство

Classes used by Response.
protected array $_classes
Результат array