PHP Класс sfWebResponse

This class manages web reponses. It supports cookies and headers management.
Автор: Fabien Potencier ([email protected])
Наследование: extends sfResponse
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$cookies
$headerOnly
$headers
$httpMetas
$javascripts
$metas
$positions
$slots
$statusCode
$statusText
$statusTexts
$stylesheets

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

Метод Описание
addCacheControlHttpHeader ( string $name, string $value = null ) Adds an control cache http header.
addHttpMeta ( string $key, string $value, boolean $replace = true ) Adds a HTTP meta header.
addJavascript ( string $file, string $position = '', string $options = [] ) Adds javascript code to the current web response.
addMeta ( string $key, string $value, boolean $replace = true, boolean $escape = true ) Adds a meta header.
addStylesheet ( string $file, string $position = '', string $options = [] ) Adds a stylesheet to the current web response.
addVaryHttpHeader ( string $header ) Adds vary to a http header.
clearHttpHeaders ( ) Cleans HTTP headers from the current web response.
clearJavascripts ( ) Clear all previously added javascripts
clearStylesheets ( ) Clear all previously added stylesheets
copyProperties ( sfWebResponse $response ) Copies all properties from a given sfWebResponse object to the current one.
getCharset ( ) : string Gets the current charset as defined by the content type.
getContentType ( ) : array Gets response content type.
getCookies ( ) : array Retrieves cookies from the current web response.
getDate ( string $timestamp, string $type = 'rfc1123' ) : string Retrieves a formated date.
getHttpHeader ( string $name, string $default = null ) : string Gets HTTP header current value.
getHttpHeaders ( ) : string Retrieves HTTP headers from the current web response.
getHttpMetas ( ) : string Retrieves meta headers for the current web response.
getJavascripts ( string $position = self::ALL ) : array Retrieves javascript files from the current web response.
getMetas ( ) : array Retrieves all meta headers.
getPositions ( ) : array Returns the available position names for stylesheets and javascripts in order.
getSlots ( ) : string Retrieves slots from the current web response.
getStatusCode ( ) : integer Retrieves status code for the current web response.
getStatusText ( ) : string Retrieves status text for the current web response.
getStylesheets ( string $position = self::ALL ) : array Retrieves stylesheets for the current web response.
getTitle ( ) : string Retrieves title for the current web response.
hasHttpHeader ( string $name ) : boolean Checks if response has given HTTP header.
initialize ( sfEventDispatcher $dispatcher, array $options = [] ) : boolean Initializes this sfWebResponse.
isHeaderOnly ( ) : boolean Returns if the response must only consist of HTTP headers.
merge ( sfWebResponse $response ) Merges all properties from a given sfWebResponse object to the current one.
prependTitle ( string $title, string $separator = ' - ', boolean $escape = true ) Preprend title
removeJavascript ( string $file ) Removes a JavaScript file from the current web response.
removeStylesheet ( string $file ) Removes a stylesheet from the current web response.
send ( ) Sends the HTTP headers and the content.
sendContent ( ) Send content for the current web response.
sendHttpHeaders ( ) Sends HTTP headers and cookies. Only the first invocation of this method will send the headers.
serialize ( )
setContentType ( string $value ) Sets response content type.
setCookie ( string $name, string $value, string $expire = null, string $path = '/', string $domain = '', boolean $secure = false, boolean $httpOnly = false ) Sets a cookie.
setHeaderOnly ( boolean $value = true ) Sets if the response consist of just HTTP headers.
setHttpHeader ( string $name, string $value, boolean $replace = true ) Sets a HTTP header.
setSlot ( string $name, string $content ) Sets a slot content.
setStatusCode ( string $code, string $name = null ) Sets response status code.
setTitle ( string $title, boolean $escape = true ) Sets title for the current web response.
unserialize ( $serialized )

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

Метод Описание
fixContentType ( string $contentType ) : string Fixes the content type by adding the charset for text content types.
normalizeHeaderName ( string $name ) : string Retrieves a normalized Header.
validatePosition ( string $position ) Validate a position name.

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

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

Adds an control cache http header.
public addCacheControlHttpHeader ( string $name, string $value = null )
$name string HTTP header
$value string Value for the http header

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

Adds a HTTP meta header.
public addHttpMeta ( string $key, string $value, boolean $replace = true )
$key string Key to replace
$value string HTTP meta header value (if null, remove the HTTP meta)
$replace boolean Replace or not

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

Adds javascript code to the current web response.
public addJavascript ( string $file, string $position = '', string $options = [] )
$file string The JavaScript file
$position string Position
$options string Javascript options

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

Adds a meta header.
public addMeta ( string $key, string $value, boolean $replace = true, boolean $escape = true )
$key string Name of the header
$value string Meta header value (if null, remove the meta)
$replace boolean true if it's replaceable
$escape boolean true for escaping the header

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

Adds a stylesheet to the current web response.
public addStylesheet ( string $file, string $position = '', string $options = [] )
$file string The stylesheet file
$position string Position
$options string Stylesheet options

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

Adds vary to a http header.
public addVaryHttpHeader ( string $header )
$header string HTTP header

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

Cleans HTTP headers from the current web response.
public clearHttpHeaders ( )

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

Clear all previously added javascripts
public clearJavascripts ( )

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

Clear all previously added stylesheets
public clearStylesheets ( )

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

Copies all properties from a given sfWebResponse object to the current one.
public copyProperties ( sfWebResponse $response )
$response sfWebResponse An sfWebResponse instance

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

Fixes the content type by adding the charset for text content types.
protected fixContentType ( string $contentType ) : string
$contentType string The content type
Результат string The content type with the charset if needed

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

Gets the current charset as defined by the content type.
public getCharset ( ) : string
Результат string The current charset

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

Gets response content type.
public getContentType ( ) : array
Результат array

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

Retrieves cookies from the current web response.
public getCookies ( ) : array
Результат array Cookies

getDate() публичный статический Метод

Retrieves a formated date.
public static getDate ( string $timestamp, string $type = 'rfc1123' ) : string
$timestamp string Timestamp
$type string Format type
Результат string Formatted date

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

Gets HTTP header current value.
public getHttpHeader ( string $name, string $default = null ) : string
$name string HTTP header name
$default string Default value returned if named HTTP header is not found
Результат string

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

Retrieves HTTP headers from the current web response.
public getHttpHeaders ( ) : string
Результат string HTTP headers

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

Retrieves meta headers for the current web response.
public getHttpMetas ( ) : string
Результат string Meta headers

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

By default, the position is sfWebResponse::ALL, and the method returns all javascripts ordered by position.
public getJavascripts ( string $position = self::ALL ) : array
$position string The position
Результат array An associative array of javascript files as keys and options as values

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

Retrieves all meta headers.
public getMetas ( ) : array
Результат array List of meta headers

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

Returns the available position names for stylesheets and javascripts in order.
public getPositions ( ) : array
Результат array An array of position names

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

Retrieves slots from the current web response.
public getSlots ( ) : string
Результат string Javascript code

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

Retrieves status code for the current web response.
public getStatusCode ( ) : integer
Результат integer Status code

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

Retrieves status text for the current web response.
public getStatusText ( ) : string
Результат string Status text

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

By default, the position is sfWebResponse::ALL, and the method returns all stylesheets ordered by position.
public getStylesheets ( string $position = self::ALL ) : array
$position string The position
Результат array An associative array of stylesheet files as keys and options as values

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

Retrieves title for the current web response.
public getTitle ( ) : string
Результат string Title

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

Checks if response has given HTTP header.
public hasHttpHeader ( string $name ) : boolean
$name string HTTP header name
Результат boolean

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

Available options: * charset: The charset to use (utf-8 by default) * content_type: The content type (text/html by default) * send_http_headers: Whether to send HTTP headers or not (true by default) * http_protocol: The HTTP protocol to use for the response (HTTP/1.0 by default)
См. также: sfResponse
public initialize ( sfEventDispatcher $dispatcher, array $options = [] ) : boolean
$dispatcher sfEventDispatcher An sfEventDispatcher instance
$options array An array of options
Результат boolean true, if initialization completes successfully, otherwise false

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

Returns if the response must only consist of HTTP headers.
public isHeaderOnly ( ) : boolean
Результат boolean returns true if, false otherwise

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

Merges all properties from a given sfWebResponse object to the current one.
public merge ( sfWebResponse $response )
$response sfWebResponse An sfWebResponse instance

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

Retrieves a normalized Header.
protected normalizeHeaderName ( string $name ) : string
$name string Header name
Результат string Normalized header

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

Preprend title
public prependTitle ( string $title, string $separator = ' - ', boolean $escape = true )
$title string Title name
$separator string Separator string (default: " - ")
$escape boolean true, for escaping the title

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

Removes a JavaScript file from the current web response.
public removeJavascript ( string $file )
$file string The Javascript file to remove

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

Removes a stylesheet from the current web response.
public removeStylesheet ( string $file )
$file string The stylesheet file to remove

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

Sends the HTTP headers and the content.
public send ( )

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

Send content for the current web response.
public sendContent ( )

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

Subsequent invocations will silently do nothing. This allows certain actions to send headers early, while still using the standard controller.
public sendHttpHeaders ( )

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

См. также: sfResponse
public serialize ( )

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

Sets response content type.
public setContentType ( string $value )
$value string Content type

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

Sets a cookie.
public setCookie ( string $name, string $value, string $expire = null, string $path = '/', string $domain = '', boolean $secure = false, boolean $httpOnly = false )
$name string HTTP header name
$value string Value for the cookie
$expire string Cookie expiration period
$path string Path
$domain string Domain name
$secure boolean If secure
$httpOnly boolean If uses only HTTP

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

Sets if the response consist of just HTTP headers.
public setHeaderOnly ( boolean $value = true )
$value boolean

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

Sets a HTTP header.
public setHttpHeader ( string $name, string $value, boolean $replace = true )
$name string HTTP header name
$value string Value (if null, remove the HTTP header)
$replace boolean Replace for the value

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

Sets a slot content.
public setSlot ( string $name, string $content )
$name string Slot name
$content string Content

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

Sets response status code.
public setStatusCode ( string $code, string $name = null )
$code string HTTP status code
$name string HTTP status text

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

Sets title for the current web response.
public setTitle ( string $title, boolean $escape = true )
$title string Title name
$escape boolean true, for escaping the title

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

См. также: sfResponse
public unserialize ( $serialized )

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

Validate a position name.
protected validatePosition ( string $position )
$position string

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

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

protected $cookies

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

protected $headerOnly

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

protected $headers

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

protected $httpMetas

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

protected $javascripts

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

protected $metas

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

protected $positions

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

protected $slots

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

protected $statusCode

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

protected $statusText

$statusTexts защищенное статическое свойство

protected static $statusTexts

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

protected $stylesheets