X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fpocoaddress.php;h=22d4d02b13d8d08e147c7d7b716d3978b22af084;hb=33e2f5b449d477e55bda7029f9e826d889e41eb5;hp=60873bdc42cd6f7e56c84d415004ea02f2131895;hpb=99454be38cf1dc7f962441d23ccc0a59e7b05f3d;p=quix0rs-gnu-social.git diff --git a/lib/pocoaddress.php b/lib/pocoaddress.php index 60873bdc42..22d4d02b13 100644 --- a/lib/pocoaddress.php +++ b/lib/pocoaddress.php @@ -42,15 +42,31 @@ class PoCoAddress // @todo Other address fields function asString() + { + $xs = new XMLStringer(true); + $this->outputTo($xs); + return $xs->getString(); + } + + function outputTo($xo) { if (!empty($this->formatted)) { - $xs = new XMLStringer(true); - $xs->elementStart('poco:address'); - $xs->element('poco:formatted', null, common_xml_safe_str($this->formatted)); - $xs->elementEnd('poco:address'); - return $xs->getString(); + $xo->elementStart('poco:address'); + $xo->element('poco:formatted', null, common_xml_safe_str($this->formatted)); + $xo->elementEnd('poco:address'); } + } - return null; + /** + * Return this PoCo address as an array suitable for serializing in JSON + * + * @return array the address + */ + + function asArray() + { + if (!empty($this->formatted)) { + return array('formatted' => $this->formatted); + } } }