コード例 #1
0
ファイル: At247.php プロジェクト: BenCavens/bpost
 /**
  * @param  \SimpleXMLElement $xml
  * @return At247
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $at247 = new At247();
     if (isset($xml->{'at24-7'}->product) && $xml->{'at24-7'}->product != '') {
         $at247->setProduct((string) $xml->{'at24-7'}->product);
     }
     if (isset($xml->{'at24-7'}->options)) {
         foreach ($xml->{'at24-7'}->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);
             }
             $at247->addOption($option);
         }
     }
     if (isset($xml->{'at24-7'}->weight) && $xml->{'at24-7'}->weight != '') {
         $at247->setWeight((int) $xml->{'at24-7'}->weight);
     }
     if (isset($xml->{'at24-7'}->memberId) && $xml->{'at24-7'}->memberId != '') {
         $at247->setMemberId((string) $xml->{'at24-7'}->memberId);
     }
     if (isset($xml->{'at24-7'}->receiverName) && $xml->{'at24-7'}->receiverName != '') {
         $at247->setReceiverName((string) $xml->{'at24-7'}->receiverName);
     }
     if (isset($xml->{'at24-7'}->receiverCompany) && $xml->{'at24-7'}->receiverCompany != '') {
         $at247->setReceiverCompany((string) $xml->{'at24-7'}->receiverCompany);
     }
     if (isset($xml->{'at24-7'}->parcelsDepotId) && $xml->{'at24-7'}->parcelsDepotId != '') {
         $at247->setParcelsDepotId((string) $xml->{'at24-7'}->parcelsDepotId);
     }
     if (isset($xml->{'at24-7'}->parcelsDepotName) && $xml->{'at24-7'}->parcelsDepotName != '') {
         $at247->setParcelsDepotName((string) $xml->{'at24-7'}->parcelsDepotName);
     }
     if (isset($xml->{'at24-7'}->parcelsDepotAddress)) {
         $parcelsDepotAddressData = $xml->{'at24-7'}->parcelsDepotAddress->children('http://schema.post.be/shm/deepintegration/v3/common');
         $at247->setParcelsDepotAddress(ParcelsDepotAddress::createFromXML($parcelsDepotAddressData));
     }
     return $at247;
 }