Example #1
0
 /**
  * Parse node values from xml nodes
  *
  * @param \DOMElement $childNode
  * @return array
  */
 protected function parseNodes($childNode)
 {
     $output = [];
     switch ($childNode->nodeName) {
         case 'vars':
             $moduleName = $childNode->getAttribute('module');
             $output[$childNode->tagName][$moduleName] = $this->parseVarElement($childNode);
             break;
         case 'exclude':
             /** @var $itemNode \DOMElement */
             foreach ($childNode->getElementsByTagName('item') as $itemNode) {
                 $itemType = $itemNode->getAttribute('type');
                 $output[$childNode->tagName][$itemType][] = $itemNode->nodeValue;
             }
             break;
         case 'media':
             foreach ($childNode->childNodes as $mediaNode) {
                 if ($mediaNode instanceof \DOMElement) {
                     $mediaNodesArray = $this->extractorPool->nodeProcessor($mediaNode->tagName)->process($mediaNode, $childNode->tagName);
                     $output = array_merge_recursive($output, $mediaNodesArray);
                 }
             }
             break;
     }
     return $output;
 }
Example #2
0
 /**
  * Extract configuration data from the DOM structure
  *
  * @param \DOMDocument $dom
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _extractData(\DOMDocument $dom)
 {
     $result = [];
     /** @var $varsNode \DOMElement */
     foreach ($dom->childNodes->item(0)->childNodes as $childNode) {
         switch ($childNode->tagName) {
             case 'vars':
                 $moduleName = $childNode->getAttribute('module');
                 $result[$childNode->tagName][$moduleName] = $this->parseVarElement($childNode);
                 break;
             case 'exclude':
                 /** @var $itemNode \DOMElement */
                 foreach ($childNode->getElementsByTagName('item') as $itemNode) {
                     $itemType = $itemNode->getAttribute('type');
                     $result[$childNode->tagName][$itemType][] = $itemNode->nodeValue;
                 }
                 break;
             case 'media':
                 foreach ($childNode->childNodes as $mediaNode) {
                     if ($mediaNode instanceof \DOMElement) {
                         $mediaNodesArray = $this->extractorPool->nodeProcessor($mediaNode->tagName)->process($mediaNode, $childNode->tagName);
                         $result = array_merge($result, $mediaNodesArray);
                     }
                 }
                 break;
         }
     }
     return $result;
 }