1 | <?php |
||
25 | class XmlResponseFormatter extends Component implements ResponseFormatterInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var string the Content-Type header for the response |
||
29 | */ |
||
30 | public $contentType = 'application/xml'; |
||
31 | /** |
||
32 | * @var string the XML version |
||
33 | */ |
||
34 | public $version = '1.0'; |
||
35 | /** |
||
36 | * @var string the XML encoding. If not set, it will use the value of [[Response::charset]]. |
||
37 | */ |
||
38 | public $encoding; |
||
39 | /** |
||
40 | * @var string the name of the root element. |
||
41 | */ |
||
42 | public $rootTag = 'response'; |
||
43 | /** |
||
44 | * @var string the name of the elements that represent the array elements with numeric keys. |
||
45 | */ |
||
46 | public $itemTag = 'item'; |
||
47 | /** |
||
48 | * @var bool whether to interpret objects implementing the [[\Traversable]] interface as arrays. |
||
49 | * Defaults to `true`. |
||
50 | * @since 2.0.7 |
||
51 | */ |
||
52 | public $useTraversableAsArray = true; |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Formats the specified response. |
||
57 | * @param Response $response the response to be formatted. |
||
58 | */ |
||
59 | 15 | public function format($response) |
|
74 | |||
75 | /** |
||
76 | * @param DOMElement $element |
||
77 | * @param mixed $data |
||
78 | */ |
||
79 | 14 | protected function buildXml($element, $data) |
|
113 | |||
114 | /** |
||
115 | * Formats scalar value to use in XML text node |
||
116 | * |
||
117 | * @param int|string|bool $value |
||
118 | * @return string |
||
119 | * @since 2.0.11 |
||
120 | */ |
||
121 | protected function formatScalarValue($value) |
||
133 | } |
||
134 |