Definition at line 10 of file Xml.php.
◆ __construct()
Initialize dependencies.
- Parameters
-
\Magento\Framework\Xml\Generator | $xmlGenerator | |
Definition at line 37 of file Xml.php.
39 $this->_xmlGenerator = $xmlGenerator;
◆ _formatData()
_formatData |
( |
|
$data, |
|
|
|
$isRoot = false |
|
) |
| |
|
protected |
Reformat mixed data to multidimensional array.
This method is recursive.
- Parameters
-
array | \Magento\Framework\DataObject | $data | |
bool | $isRoot | |
- Returns
- array
- Exceptions
-
Definition at line 77 of file Xml.php.
88 $isAssoc = !preg_match(
'/^\d+$/', implode(array_keys(
$data),
''));
99 return $formattedData;
elseif(isset( $params[ 'redirect_parent']))
_formatData($data, $isRoot=false)
◆ _formatValue()
Prepare value in contrast with key.
- Parameters
-
- Returns
- string
Without the following transformation boolean values are rendered incorrectly
Definition at line 108 of file Xml.php.
114 $replacementMap = [
'&' =>
'&'];
115 return str_replace(array_keys($replacementMap), array_values($replacementMap),
$value);
◆ _prepareKey()
Format array key or field name to be valid array key name.
Replaces characters that are invalid in array key names.
- Parameters
-
- Returns
- string
Definition at line 126 of file Xml.php.
160 $key = str_replace(array_keys($replacementMap), array_values($replacementMap), $key);
161 $key = trim($key,
'_');
162 $prohibitedTagPattern =
'/^[0-9,.-]/';
163 if (preg_match($prohibitedTagPattern, $key)) {
164 $key = self::DEFAULT_ENTITY_ITEM_NAME .
'_' . $key;
◆ getMimeType()
◆ render()
Format object|array to valid XML.
- Parameters
-
object | array | int | string | bool | float | null | $data | |
- Returns
- string
Wrap response in a single node.
Implements RendererInterface.
Definition at line 58 of file Xml.php.
62 $formattedData = [self::XML_ROOT_NODE => $formattedData];
63 $this->_xmlGenerator->setIndexedArrayItemName(self::DEFAULT_ENTITY_ITEM_NAME)->arrayToXml($formattedData);
64 return $this->_xmlGenerator->getDom()->saveXML();
_formatData($data, $isRoot=false)
◆ $_xmlGenerator
◆ DEFAULT_ENTITY_ITEM_NAME
const DEFAULT_ENTITY_ITEM_NAME = 'item' |
This value is used to replace numeric keys while formatting data for XML output.
Definition at line 25 of file Xml.php.
◆ MIME_TYPE
const MIME_TYPE = 'application/xml' |
◆ XML_ROOT_NODE
const XML_ROOT_NODE = 'response' |
Root node in XML output.
Definition at line 20 of file Xml.php.
The documentation for this class was generated from the following file:
- vendor/magento/framework/Webapi/Rest/Response/Renderer/Xml.php