39 private $argumentParser;
48 $this->argumentParser = $argumentParser;
57 private function toArray(\DOMNode $node)
62 if ($node->hasAttributes()) {
73 switch ($node->nodeType) {
75 case XML_COMMENT_NODE:
76 case XML_CDATA_SECTION_NODE:
79 if ($node->localName === static::ARGUMENT_KEY) {
80 if (!isset(
$attributes[static::NAME_ATTRIBUTE_KEY])) {
81 throw new \InvalidArgumentException(
82 'Attribute "' . static::NAME_ATTRIBUTE_KEY .
'" is absent in the attributes node.' 85 $result[
$attributes[static::NAME_ATTRIBUTE_KEY] ] = $this->argumentParser->parse($node);
87 list(
$arguments, $childResult) = $this->convertChildNodes($node);
104 private function getComponentName(\DOMNode $node)
107 if (!$node->hasAttributes()) {
111 if (
$attribute->name == static::NAME_ATTRIBUTE_KEY) {
135 foreach (
$result as $componentName => $componentData) {
136 $schemaMap[$componentName] = $this->processMap($componentData,
$result);
148 private function processMap($componentData, $sourceMap)
151 if (isset($componentData[static::INCLUDE_KEY])) {
152 if (isset($sourceMap[$componentData[static::INCLUDE_KEY]])) {
153 $result = array_replace_recursive(
154 $this->processMap($sourceMap[$componentData[static::INCLUDE_KEY]], $sourceMap),
160 if (isset($componentData[static::CURRENT_SCHEMA_KEY])) {
161 $result = array_replace_recursive($componentData[static::CURRENT_SCHEMA_KEY],
$result);
173 private function convertChildNodes(\DOMNode $node)
177 foreach ($node->childNodes as $itemNode) {
178 if (empty($itemNode->localName)) {
181 if ($itemNode->localName === static::ARGUMENT_KEY) {
184 $childResult[$this->getComponentName($itemNode)] = $this->toArray($itemNode);
197 private function processArguments(array
$arguments)
__construct(Parser $argumentParser)