[Pkg-owncloud-commits] [php-sabre-vobject] 157/341: Remove the `getXmlValue` method.

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 13:35:43 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 6e53b69b5ebf3721920f935de4215dc9a9bd7631
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date:   Mon Jan 19 15:10:42 2015 +0100

    Remove the `getXmlValue` method.
---
 lib/Property.php                  | 15 +---------
 lib/Property/Float.php            | 48 +++++++------------------------
 lib/Property/ICalendar/Period.php | 48 +++++++++++++++++--------------
 lib/Property/Text.php             | 60 +++++++++++----------------------------
 4 files changed, 56 insertions(+), 115 deletions(-)

diff --git a/lib/Property.php b/lib/Property.php
index bd03dc1..77fc9c3 100644
--- a/lib/Property.php
+++ b/lib/Property.php
@@ -336,19 +336,6 @@ abstract class Property extends Node {
     }
 
     /**
-     * Returns the value, in the format it should be encoded for XML.
-     *
-     * This method must always return an array.
-     *
-     * @return array
-     */
-    function getXmlValue() {
-
-        return $this->getJsonValue();
-
-    }
-
-    /**
      * This method serializes the data into XML. This is used to create xCard or
      * xCal documents.
      *
@@ -403,7 +390,7 @@ abstract class Property extends Node {
      */
     protected function xmlSerializeValue(Xml\Writer $writer) {
 
-        foreach ($this->getXmlValue() as $value) {
+        foreach ($this->getJsonValue() as $value) {
 
             $writer->startElement(strtolower($this->getValueType()));
                 $writer->write($value);
diff --git a/lib/Property/Float.php b/lib/Property/Float.php
index 1b2560b..09b7966 100644
--- a/lib/Property/Float.php
+++ b/lib/Property/Float.php
@@ -112,40 +112,6 @@ class Float extends Property {
     }
 
     /**
-     * Returns the value, in the format it should be encoded for XML.
-     *
-     * This method must always return an array.
-     *
-     * @return array
-     */
-    public function getXmlValue() {
-
-        $val = array_map('floatval', $this->getParts());
-
-        // Special-casing the GEO property.
-        //
-        // See:
-        // http://tools.ietf.org/html/rfc6321#section-3.4.1.2
-        if ($this->name === 'GEO') {
-            return [
-                [
-                    [
-                        'name' => 'latitude',
-                        'value' => $val[0]
-                    ],
-                    [
-                        'name' => 'longitude',
-                        'value' => $val[1]
-                    ]
-                ]
-            ];
-        }
-
-        return $val;
-
-    }
-
-    /**
      * This method serializes only the value of a property. This is used to
      * create xCard or xCal documents.
      *
@@ -159,9 +125,17 @@ class Float extends Property {
         // See:
         // http://tools.ietf.org/html/rfc6321#section-3.4.1.2
         if ($this->name === 'GEO') {
-            foreach ($this->getXmlValue() as $value) {
-                $writer->write($value);
-            }
+
+            $value = array_map('floatval', $this->getParts());
+
+            $writer->startElement('latitude');
+                $writer->write($value[0]);
+            $writer->endElement();
+
+            $writer->startElement('longitude');
+                $writer->write($value[1]);
+            $writer->endElement();
+
         }
         else {
             parent::xmlSerializeValue($writer);
diff --git a/lib/Property/ICalendar/Period.php b/lib/Property/ICalendar/Period.php
index 7e53104..d36a2e3 100644
--- a/lib/Property/ICalendar/Period.php
+++ b/lib/Property/ICalendar/Period.php
@@ -4,7 +4,8 @@ namespace Sabre\VObject\Property\ICalendar;
 
 use
     Sabre\VObject\Property,
-    Sabre\VObject\DateTimeParser;
+    Sabre\VObject\DateTimeParser,
+    Sabre\Xml;
 
 /**
  * Period property
@@ -126,28 +127,33 @@ class Period extends Property {
     }
 
     /**
-     * Returns the value, in the format it should be encoded for XML.
+     * This method serializes only the value of a property. This is used to
+     * create xCard or xCal documents.
      *
-     * This method must always return an array.
-     *
-     * @return array
+     * @param Xml\Writer $writer  XML writer.
+     * @return void
      */
-    public function getXmlValue() {
-
-        $val = parent::getXmlValue();
-
-        return [
-            [
-                [
-                    'name' => 'start',
-                    'value' => $val[0][0]
-                ],
-                [
-                    'name' => $val[0][1][0] === 'P' ? 'duration' : 'end',
-                    'value' => $val[0][1]
-                ]
-            ]
-        ];
+    protected function xmlSerializeValue(Xml\Writer $writer) {
+
+        $writer->startElement(strtolower($this->getValueType()));
+
+        $value = $this->getJsonValue();
+
+        $writer->startElement('start');
+            $writer->write($value[0][0]);
+        $writer->endElement();
+
+        if ($value[0][1][0] === 'P') {
+            $writer->startElement('duration');
+        }
+        else {
+            $writer->startElement('end');
+        }
+
+        $writer->write($value[0][1]);
+        $writer->endElement();
+
+        $writer->endElement();
 
     }
 
diff --git a/lib/Property/Text.php b/lib/Property/Text.php
index 6e0167a..1832d60 100644
--- a/lib/Property/Text.php
+++ b/lib/Property/Text.php
@@ -288,15 +288,13 @@ class Text extends Property {
     }
 
     /**
-     * Returns the value, in the format it should be encoded for XML.
-     *
-     * This method must always return an array.
+     * This method serializes only the value of a property. This is used to
+     * create xCard or xCal documents.
      *
-     * @return array
+     * @param Xml\Writer $writer  XML writer.
+     * @return void
      */
-    public function getXmlValue() {
-
-        $val = parent::getXmlValue();
+    protected function xmlSerializeValue(Xml\Writer $writer) {
 
         // Special-casing the REQUEST-STATUS property.
         //
@@ -304,48 +302,24 @@ class Text extends Property {
         // http://tools.ietf.org/html/rfc6321#section-3.4.1.3
         if ($this->name === 'REQUEST-STATUS') {
 
-            $handle = [
-                [
-                    'name' => 'code',
-                    'value' => $val[0][0]
-                ],
-                [
-                    'name' => 'description',
-                    'value' => $val[0][1]
-                ]
-            ];
-
-            if(isset($val[0][2]))
-                $handle[] = [
-                    'name' => 'data',
-                    'value' => $val[0][2]
-                ];
+            $value = $this->getJsonValue();
 
-            return [$handle];
+            $writer->startElement('code');
+                $writer->write($value[0][0]);
+            $writer->endElement();
 
-        }
+            $writer->startElement('description');
+                $writer->write($value[0][1]);
+            $writer->endElement();
 
-        return $val;
+            if (isset($value[0][2])) {
 
-    }
+                $writer->startElement('data');
+                    $writer->write($value[0][2]);
+                $writer->endElement();
 
-    /**
-     * This method serializes only the value of a property. This is used to
-     * create xCard or xCal documents.
-     *
-     * @param Xml\Writer $writer  XML writer.
-     * @return void
-     */
-    protected function xmlSerializeValue(Xml\Writer $writer) {
-
-        // Special-casing the REQUEST-STATUS property.
-        //
-        // See:
-        // http://tools.ietf.org/html/rfc6321#section-3.4.1.3
-        if ($this->name === 'REQUEST-STATUS') {
-            foreach ($this->getXmlValue() as $value) {
-                $writer->write($value);
             }
+
         }
         else {
             parent::xmlSerializeValue($writer);

-- 
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