Example #1
0
 /**
  * registerMeta
  * @param ClassMeta $meta
  */
 protected function registerMeta(ClassMeta $meta)
 {
     $key = $this->getKey($meta->getClassName());
     $this->data[$key] = $meta;
 }
Example #2
0
 /**
  * serializeProperty
  *
  * @param ClassMeta $meta
  * @param $propName
  * @param $value
  * @param \DOMElement $target
  * @throws \RuntimeException
  */
 private static function serializeProperty(ClassMeta $meta, $propName, $value, \DOMElement $target)
 {
     if ($value === null) {
         return;
     }
     $valueType = self::getValueType($value);
     $attrName = $meta->getAttributeName($propName, $valueType);
     if ($attrName) {
         $target->setAttribute($attrName, self::formatAtomicValue($value));
     }
     $elementName = $meta->getElementName($propName, $valueType);
     if ($elementName) {
         $child = $target->ownerDocument->createElement($elementName);
         if (self::isObject($value)) {
             self::serializeObject($value, $child);
         } else {
             $text = self::formatAtomicValue($value);
             $child->appendChild($target->ownerDocument->createTextNode($text));
         }
         $target->appendChild($child);
     }
     if (!$attrName && !$elementName) {
         throw new \RuntimeException("Don't know how to serialize value of type '{$valueType}' for property '{$propName}' of class '{$meta->getClassName()}'");
     }
 }