Exemplo n.º 1
0
 public function write()
 {
     $gpx = new \SimpleXMLElement("<gpx></gpx>");
     foreach ($this->document->getAttributes() as $index => $attribute) {
         $gpx->addAttribute($index, $attribute);
     }
     foreach ($this->document->readyXML() as $index => $value) {
         if (!$value instanceof Collection) {
             if (is_object($value)) {
                 $child = $gpx->addChild($index);
                 return $this->recursiveFunction($value, $child);
             } else {
                 $gpx->addChild($index, $value);
             }
         }
     }
     //$this->recursiveFunction($this->document, $gpx);
     /*foreach ($this->document->readyXML() as $index => $value) {
                 $child = $gpx->addChild($index);
     
                 if (! $value instanceof Collection) {
                     foreach ($value->readyXML() as $index => $value) {
                         if (is_object($value)) {
                             $grandChild = $gpx->addChild($index);
     
                             foreach ($value->readyXML() as $index => $value) {
                                 $grandChild->addChild($index);
     
                                 if (is_object($value)) {
                                     $greatGrandChild = $gpx->addChild($index);
     
                                     foreach ($value->readyXML() as $index => $value) {
                                         $greatGrandChild->addChild($index, $value);
                                     }
                                 } else {
                                     $grandChild->addChild($index, $value);
                                 }
                             }
                         } else {
                             $child->addChild($index, $value);
                         }
                     }
                 }
             }*/
     if ($this->document->getMetadata() instanceof Metadata) {
         $metadata = $gpx->addChild('metadata');
         foreach ($this->document->getMetadata()->readyXML() as $index => $value) {
             if (is_object($value)) {
             }
         }
         $metadata->addChild('name', $this->document->getMetadata()->getName());
     }
     if ($this->document->getWaypointCollection()->hasValues()) {
         $gpx->addChild('wpt');
     }
     //$gpx->addChild('wpt');
     /*foreach ($this->document->getWaypoints() as $waypoints) {
           foreach ($waypoints->getAttributes() as $index => $attribute) {
               $gpx->addAttribute($index, $attribute);
           }
       }*/
     $test = $gpx->asXML();
     /*$properties = $this->findMethods($this->document);
     
             foreach($properties as $index => $value) {
                 echo 'hi';
             }*/
 }