[Pkg-owncloud-commits] [php-sabre-vobject] 202/341: Serialize basic vCard to xCard.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:48 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit d3eeb7ad71d3d2cab72f561eca09b3e54d916adf
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Mon Jan 26 14:37:45 2015 +0100
Serialize basic vCard to xCard.
---
lib/Component/VCard.php | 28 +++++++++++++++++++++++++++-
tests/VObject/Parser/XmlTest.php | 22 ++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php
index 07aa705..9284c14 100644
--- a/lib/Component/VCard.php
+++ b/lib/Component/VCard.php
@@ -3,7 +3,8 @@
namespace Sabre\VObject\Component;
use
- Sabre\VObject;
+ Sabre\VObject,
+ Sabre\Xml;
/**
* The VCard component
@@ -430,6 +431,31 @@ class VCard extends VObject\Document {
}
/**
+ * This method serializes the data into XML. This is used to create xCard or
+ * xCal documents.
+ *
+ * @param Xml\Writer $writer XML writer.
+ * @return void
+ */
+ function xmlSerialize(Xml\Writer $writer) {
+
+ $writer->startElement(strtolower($this->name));
+
+ foreach ($this->children as $property) {
+
+ if ($property->name === 'VERSION') {
+ continue;
+ }
+
+ $property->xmlSerialize($writer);
+
+ }
+
+ $writer->endElement();
+
+ }
+
+ /**
* Returns the default class for a property name.
*
* @param string $propertyName
diff --git a/tests/VObject/Parser/XmlTest.php b/tests/VObject/Parser/XmlTest.php
index 44a5baa..a3936f1 100644
--- a/tests/VObject/Parser/XmlTest.php
+++ b/tests/VObject/Parser/XmlTest.php
@@ -1109,6 +1109,28 @@ XML
}
+ function testRFC6351Basic() {
+
+ $this->assertXMLReflexivelyEqualsToMimeDir(
+<<<XML
+<?xml version="1.0" encoding="UTF-8"?>
+<vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0">
+ <vcard>
+ <fn>
+ <text>J. Doe</text>
+ </fn>
+ </vcard>
+</vcards>
+XML
+,
+ 'BEGIN:VCARD' . CRLF .
+ 'VERSION:4.0' . CRLF .
+ 'FN:J. Doe' . CRLF .
+ 'END:VCARD' . CRLF
+ );
+
+ }
+
function testRFC6351Example1() {
$this->assertXMLEqualsToMimeDir(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list