Exemplo n.º 1
0
 private function marshalCollection($object, PiBX_AST_Collection $ast)
 {
     $getter = $ast->getGetMethod();
     $collectionItems = $object->{$getter}();
     $lastNode = $this->parentDomNode;
     $this->parentDomNode = $this->currentDomNode;
     foreach ($collectionItems as &$item) {
         if ($ast->hasChildren()) {
             $childrenCount = $ast->countChildren();
             for ($i = 0; $i < $childrenCount; $i++) {
                 $child = $ast->get($i);
                 if (is_object($item)) {
                     // TODO is abstract mapping collection?
                     $classToMarshal = get_class($item);
                     $classAst = $this->binding->getASTForClass($classToMarshal);
                     $structureName = $child->getName();
                     $classAst->setName($structureName);
                     $this->marshalObject($item, $classAst);
                 } else {
                     // this collection is just a list of (scalar) values
                     $this->marshalObject($item, $child);
                 }
             }
         }
     }
     $this->parentDomNode = $lastNode;
 }