Пример #1
0
 private function addChild(SimpleXMLElement &$xmltree, Entities\BaseEntity $entity)
 {
     $xmlentitychild = $xmltree->addChild($entity->getXmlName());
     foreach ($entity->getAttributeKeys() as $attributeKey) {
         if ($entity->{$attributeKey} instanceof Entities\BaseEntity) {
             // Add child for foreign entity
             $this->addChild($xmlentitychild, $entity->{$attributeKey});
         } elseif (is_array($entity->{$attributeKey}) && $entity->isChildEntity($attributeKey)) {
             // Add subtree with childs for child entities
             $this->addCollectionChilds($attributeKey, $xmlentitychild, $entity->{$attributeKey});
         } else {
             // Add xml child with attribute
             if ($entity->{$attributeKey} === true) {
                 $entity->{$attributeKey} = 'true';
             }
             if ($entity->{$attributeKey} === false) {
                 $entity->{$attributeKey} = 'false';
             }
             if ($entity->{$attributeKey} instanceof DateTime) {
                 $entity->{$attributeKey} = $entity->{$attributeKey}->format(DateTime::ISO8601);
             }
             if (!is_null($entity->{$attributeKey}) && !in_array($attributeKey, $entity->getIgnoredPutPostValues())) {
                 // Do not include empty attributes
                 $xmlentitychild->addChild($attributeKey, htmlspecialchars($entity->{$attributeKey}));
             }
         }
     }
 }
Пример #2
0
 public function getInvoices()
 {
     $response = $this->requestGet('/invoices');
     return Entities\BaseEntity::makeCollectionFromResponse('Invoice', $response['Invoices']);
 }