61 private $schemaMap = [];
76 private $converterUtils;
91 $this->reader = $reader;
92 $this->parser = $parser;
93 $this->converterUtils = $converterUtils;
102 private function toArray(\DOMNode $node)
107 if ($node->hasAttributes()) {
109 if (
$attribute->name ==
'noNamespaceSchemaLocation') {
116 switch ($node->nodeType) {
118 case XML_COMMENT_NODE:
119 case XML_CDATA_SECTION_NODE:
122 if ($node->localName === static::ARGUMENT_KEY) {
123 if (!isset(
$attributes[static::NAME_ATTRIBUTE_KEY])) {
124 throw new \InvalidArgumentException(
125 'Attribute "' . static::NAME_ATTRIBUTE_KEY .
'" is absent in the attributes node.' 128 $result[
$attributes[static::NAME_ATTRIBUTE_KEY]] = $this->argumentParser->parse($node);
130 $resultComponent = $this->convertNode($node);
131 list(
$arguments, $childResult) = $this->convertChildNodes($node);
134 $this->processArguments(
$arguments, $resultComponent),
136 $this->processChildResult($node, $childResult)
158 if (!$this->schemaMap) {
159 $this->schemaMap = $this->reader->read();
171 private function convertNode(\DOMNode $node)
173 $resultComponent = [];
174 if (empty($node->localName)
175 || !$this->converterUtils->isUiComponent($node)
176 || !isset($this->schemaMap[$node->localName])
178 return $resultComponent;
181 foreach ($this->schemaMap[$node->localName] as $componentData) {
183 foreach ($componentData as $dataKey => $dataValue) {
184 $resultParser = $this->parser->parse($dataValue, $node);
186 $result[$dataKey] = $resultParser;
189 $resultComponent = array_replace_recursive($resultComponent,
$result);
192 return $resultComponent;
202 private function processArguments(array
$arguments, array $resultComponent)
205 if (!empty(
$arguments) || !empty($resultComponent)) {
206 $result[static::DATA_ARGUMENTS_KEY] = array_replace_recursive($resultComponent,
$arguments);
217 private function processAttributes(array
$attributes)
231 private function processChildResult(\DOMNode $node, array $childResult)
234 if ($node->parentNode !==
null) {
235 $result[static::DATA_COMPONENTS_KEY] = $childResult;
249 private function convertChildNodes(\DOMNode $node)
253 for (
$i = 0, $iLength = $node->childNodes->length;
$i < $iLength; ++
$i) {
254 $itemNode = $node->childNodes->item(
$i);
255 if ($itemNode->localName ==
null) {
258 if ($itemNode->localName === static::ARGUMENT_KEY) {
260 }
elseif ($this->converterUtils->isUiComponent($itemNode)
261 && isset($this->schemaMap[$itemNode->localName])
263 $itemNodeName = $this->converterUtils->getComponentName($itemNode);
264 $childResult[$itemNodeName] = $this->
toArray($itemNode);
266 $childResult[$itemNodeName][
'uiComponentType'] = $itemNode->localName;
const DATA_COMPONENTS_KEY
elseif(isset( $params[ 'redirect_parent']))
const DATA_ATTRIBUTES_KEY
const CLASS_ATTRIBUTE_KEY
__construct(Parser $argumentParser, ParserInterface $parser, ReaderInterface $reader, ConverterUtils $converterUtils)