/**
  * Turn a record into a string
  * @param Record $object
  * @return string
  */
 public function getXML(Transformable $object)
 {
     $xml = "\n<record table='{$object->getTableName()}' id='{$object->getId()}'>";
     foreach ($object->getAttributes() as $key => $value) {
         // Need this to make sure the magic getter is called for lazy loading
         $value = $object->{$key};
         $xml .= "\n\t<{$key}>";
         if ($value instanceof XML) {
             $xml .= $value->getXML();
         } else {
             if (is_bool($value)) {
                 $xml .= $value ? "true" : "false";
             } else {
                 if (is_array($value)) {
                     $xml .= ArrayUtil::getXML($value);
                 } else {
                     $xml .= htmlspecialchars($value, ENT_COMPAT, "UTF-8", false);
                 }
             }
         }
         $xml .= "</{$key}>";
     }
     $xml .= "\n</record>";
     return $xml;
 }
예제 #2
0
 /**
  * XML representation
  * @return string XML
  */
 public function getXML()
 {
     $xml = ArrayUtil::getXML($_SERVER);
     $xml .= ArrayUtil::getXML($_REQUEST);
     $xml .= ArrayUtil::getXML($_COOKIE);
     $xml .= ArrayUtil::getXML($_FILES);
     return "<environment>{$xml}</environment>";
 }
예제 #3
0
 /**
  * @param $xml
  */
 public function add($xml, $key = null)
 {
     if ($xml instanceof XML) {
         $this->data .= $xml->getXML();
     } else {
         if ($xml instanceof DomDocument) {
             $this->data .= $xml->saveXML();
         } else {
             if (is_array($xml)) {
                 $this->data .= ArrayUtil::getXML($xml);
             } else {
                 $this->data .= $xml;
             }
         }
     }
 }