function asString()
{
$xs = new XMLStringer(true);
- $xs->elementStart('poco:urls');
- $xs->element('poco:type', null, $this->type);
- $xs->element('poco:value', null, $this->value);
+ $this->outputTo($xs);
+ return $xs->getString();
+ }
+
+ function outputTo($xo)
+ {
+ $xo->elementStart('poco:urls');
+ $xo->element('poco:type', null, $this->type);
+ $xo->element('poco:value', null, $this->value);
if (!empty($this->primary)) {
- $xs->element('poco:primary', null, 'true');
+ $xo->element('poco:primary', null, 'true');
}
- $xs->elementEnd('poco:urls');
- return $xs->getString();
+ $xo->elementEnd('poco:urls');
+ }
+
+ /**
+ * Return this PoCo URL as an array suitable for serializing in JSON
+ *
+ * @array $url the url
+ */
+
+ function asArray()
+ {
+ $url = array();
+
+ $url['type'] = $this->type;
+ $url['value'] = $this->value;
+
+ if (!empty($this->primary)) {
+ $url['primary'] = 'true';
+ }
+
+ return $url;
}
}