Ejemplo n.º 1
0
 private function createProductFromJSON($jsonItem, $descriptionJSON)
 {
     $result = array();
     foreach ($descriptionJSON as $attributeJson) {
         $attributeName = $attributeJson['attribute'];
         $attributeValue = $this->getJSON($jsonItem, $attributeJson['schema']);
         if ($attributeJson['format']) {
             $format = $attributeJson['format'];
             $attributeParser = new AttributeFormatParser($attributeValue, null);
             $attributeValue = $attributeParser->parse($format);
         }
         $result[$attributeName] = $attributeValue;
     }
     return $result;
 }
Ejemplo n.º 2
0
 private function getDOMElementAttribute(DOMNode $element, $json)
 {
     $toReturn = null;
     $resultList = $this->extractAllDOMElementsMatching($element, $json['schema']);
     if (!empty($resultList)) {
         $result = $resultList[0];
         $valueType = $json['value']['type'];
         if ($valueType == 'value') {
             $toReturn = $result->nodeValue;
         } else {
             if ($valueType == 'attribute') {
                 $attribute = $json['value']['attribute'];
                 $toReturn = $result->getAttribute($attribute);
             }
         }
     }
     if ($toReturn != null) {
         if ($json['value']['format']) {
             $format = $json['value']['format'];
             $attributeParser = new AttributeFormatParser($toReturn, null);
             $toReturn = $attributeParser->parse($format);
         }
     }
     return $toReturn;
 }