public function serializeDateTimeToXml(XmlSerializationVisitor $visitor, \DateTime $date, array $type)
 {
     if (null === $visitor->document) {
         $visitor->document = $visitor->createDocument(null, null, true);
     }
     return $visitor->document->createTextNode($date->format($this->getFormat($type)));
 }
Esempio n. 2
0
 /** @HandlerCallback("xml", direction = "serialization") */
 public function serializeToXml(XmlSerializationVisitor $visitor)
 {
     if (null === $visitor->document) {
         $visitor->document = $visitor->createDocument(null, null, false);
     }
     $visitor->document->appendChild($visitor->document->createElement($this->element, $this->value));
 }
 public function serializeFormErrorToXml(XmlSerializationVisitor $visitor, FormError $formError, array $type)
 {
     if (null === $visitor->document) {
         $visitor->document = $visitor->createDocument(null, null, true);
     }
     return $visitor->document->createCDATASection($this->getErrorMessage($formError));
 }
 public function serializeViolationToXml(XmlSerializationVisitor $visitor, ConstraintViolation $violation, array $type = null)
 {
     if (null === $visitor->document) {
         $visitor->document = $visitor->createDocument(null, null, false);
         $visitor->document->appendChild($violationNode = $visitor->document->createElement('violation'));
         $visitor->setCurrentNode($violationNode);
     } else {
         $visitor->getCurrentNode()->appendChild($violationNode = $visitor->document->createElement('violation'));
     }
     $violationNode->setAttribute('property_path', $violation->getPropertyPath());
     $violationNode->appendChild($messageNode = $visitor->document->createElement('message'));
     $messageNode->appendChild($visitor->document->createCDATASection($violation->getMessage()));
 }