Exemplo n.º 1
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return AtBpost
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $atBpost = new AtBpost();
     if (isset($xml->atBpost->product) && $xml->atBpost->product != '') {
         $atBpost->setProduct((string) $xml->atBpost->product);
     }
     if (isset($xml->atBpost->options)) {
         foreach ($xml->atBpost->options as $optionData) {
             $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common');
             if (in_array($optionData->getName(), array('infoDistributed', 'infoNextDay', 'infoReminder', 'keepMeInformed'))) {
                 $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);
             }
             $atBpost->addOption($option);
         }
     }
     if (isset($xml->atBpost->weight) && $xml->atBpost->weight != '') {
         $atBpost->setWeight((int) $xml->atBpost->weight);
     }
     if (isset($xml->atBpost->receiverName) && $xml->atBpost->receiverName != '') {
         $atBpost->setReceiverName((string) $xml->atBpost->receiverName);
     }
     if (isset($xml->atBpost->receiverCompany) && $xml->atBpost->receiverCompany != '') {
         $atBpost->setReceiverCompany((string) $xml->atBpost->receiverCompany);
     }
     if (isset($xml->atBpost->pugoId) && $xml->atBpost->pugoId != '') {
         $atBpost->setPugoId((string) $xml->atBpost->pugoId);
     }
     if (isset($xml->atBpost->pugoName) && $xml->atBpost->pugoName != '') {
         $atBpost->setPugoName((string) $xml->atBpost->pugoName);
     }
     if (isset($xml->atBpost->pugoAddress)) {
         $pugoAddressData = $xml->atBpost->pugoAddress->children('http://schema.post.be/shm/deepintegration/v3/common');
         $atBpost->setPugoAddress(PugoAddress::createFromXML($pugoAddressData));
     }
     return $atBpost;
 }
Exemplo n.º 2
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;
 }