예제 #1
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return AtHome
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $atHome = new AtHome();
     if (isset($xml->atHome->product) && $xml->atHome->product != '') {
         $atHome->setProduct((string) $xml->atHome->product);
     }
     if (isset($xml->atHome->options) and !empty($xml->atHome->options)) {
         foreach ($xml->atHome->options as $optionData) {
             $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common');
             if (in_array($optionData->getName(), array('infoDistributed'))) {
                 $option = Messaging::createFromXML($optionData);
             } else {
                 $className = '\\TijsVerkoyen\\Bpost\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName());
                 if (!method_exists($className, 'createFromXML')) {
                     throw new Exception('Not Implemented');
                 }
                 $option = call_user_func(array($className, 'createFromXML'), $optionData);
             }
             $atHome->addOption($option);
         }
     }
     if (isset($xml->atHome->weight) && $xml->atHome->weight != '') {
         $atHome->setWeight((int) $xml->atHome->weight);
     }
     if (isset($xml->atHome->openingHours) && $xml->atHome->openingHours != '') {
         throw new Exception('Not Implemented');
         $atHome->setProduct((string) $xml->atHome->openingHours);
     }
     if (isset($xml->atHome->desiredDeliveryPlace) && $xml->atHome->desiredDeliveryPlace != '') {
         $atHome->setDesiredDeliveryPlace((string) $xml->atHome->desiredDeliveryPlace);
     }
     if (isset($xml->atHome->receiver)) {
         $atHome->setReceiver(Receiver::createFromXML($xml->atHome->receiver->children('http://schema.post.be/shm/deepintegration/v3/common')));
     }
     return $atHome;
 }
예제 #2
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return International
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $international = new International();
     if (isset($xml->international->product) && $xml->international->product != '') {
         $international->setProduct((string) $xml->international->product);
     }
     if (isset($xml->international->options)) {
         foreach ($xml->international->options as $optionData) {
             $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common');
             if (in_array($optionData->getName(), array('infoDistributed'))) {
                 $option = Messaging::createFromXML($optionData);
             } else {
                 $className = '\\TijsVerkoyen\\Bpost\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName());
                 if (!method_exists($className, 'createFromXML')) {
                     throw new Exception('Not Implemented');
                 }
                 $option = call_user_func(array($className, 'createFromXML'), $optionData);
             }
             $international->addOption($option);
         }
     }
     if (isset($xml->international->parcelWeight) && $xml->international->parcelWeight != '') {
         $international->setParcelWeight((int) $xml->international->parcelWeight);
     }
     if (isset($xml->international->receiver)) {
         $receiverData = $xml->international->receiver->children('http://schema.post.be/shm/deepintegration/v3/common');
         $international->setReceiver(Receiver::createFromXML($receiverData));
     }
     if (isset($xml->international->customsInfo)) {
         $international->setCustomsInfo(CustomsInfo::createFromXML($xml->international->customsInfo));
     }
     return $international;
 }