PHP Class yii\web\XmlResponseFormatter

It is used by Response to format response data.
Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\base\Component, implements yii\web\ResponseFormatterInterface
Show file Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$contentType the Content-Type header for the response
$encoding the XML encoding. If not set, it will use the value of [[Response::charset]].
$itemTag the name of the elements that represent the array elements with numeric keys.
$rootTag the name of the root element.
$useTraversableAsArray whether to interpret objects implementing the [[\Traversable]] interface as arrays. Defaults to true.
$version the XML version

Public Methods

Method Description
format ( Response $response ) Formats the specified response.

Protected Methods

Method Description
buildXml ( DOMElement $element, mixed $data )
formatScalarValue ( integer | string | boolean $value ) : string Formats scalar value to use in XML text node

Method Details

buildXml() protected method

protected buildXml ( DOMElement $element, mixed $data )
$element DOMElement
$data mixed

format() public method

Formats the specified response.
public format ( Response $response )
$response Response the response to be formatted.

formatScalarValue() protected method

Formats scalar value to use in XML text node
Since: 2.0.11
protected formatScalarValue ( integer | string | boolean $value ) : string
$value integer | string | boolean
return string

Property Details

$contentType public property

the Content-Type header for the response
public $contentType

$encoding public property

the XML encoding. If not set, it will use the value of [[Response::charset]].
public $encoding

$itemTag public property

the name of the elements that represent the array elements with numeric keys.
public $itemTag

$rootTag public property

the name of the root element.
public $rootTag

$useTraversableAsArray public property

whether to interpret objects implementing the [[\Traversable]] interface as arrays. Defaults to true.
Since: 2.0.7
public $useTraversableAsArray

$version public property

the XML version
public $version