Example #1
0
 /**
  * Presents as xml
  * @param string|null $node default null
  * @return \SimpleXMLElement
  */
 public function asXml($node = null)
 {
     $object = System::getObject($this);
     $properties = $object->getProperties();
     $xml = '';
     foreach ($properties as $property) {
         $value = $property->getValue($this);
         if (is_object($value)) {
             $stdObject = new self($value);
             $value = $stdObject->asXml();
         }
         $xml .= '<' . $property->getName() . '>' . $value . '</' . $property->getName() . '>';
     }
     !is_null($node) ?: ($node = $object->getShortName());
     return new \SimpleXMLElement('<' . $node . '>' . $xml . '</' . $node . '>');
 }