/** * 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 GEO property. // // See: // http://tools.ietf.org/html/rfc6321#section-3.4.1.2 if ($this->name === 'GEO') { $value = array_map('floatval', $this->getParts()); $writer->writeElement('latitude', $value[0]); $writer->writeElement('longitude', $value[1]); } else { parent::xmlSerializeValue($writer); } }
/** * 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) { $values = $this->getParts(); $map = function ($items) use($values, $writer) { foreach ($items as $i => $item) { $writer->writeElement($item, !empty($values[$i]) ? $values[$i] : null); } }; switch ($this->name) { // Special-casing the REQUEST-STATUS property. // // See: // http://tools.ietf.org/html/rfc6321#section-3.4.1.3 case 'REQUEST-STATUS': $writer->writeElement('code', $values[0]); $writer->writeElement('description', $values[1]); if (isset($values[2])) { $writer->writeElement('data', $values[2]); } break; case 'N': $map(['surname', 'given', 'additional', 'prefix', 'suffix']); break; case 'GENDER': $map(['sex', 'text']); break; case 'ADR': $map(['pobox', 'ext', 'street', 'locality', 'region', 'code', 'country']); break; case 'CLIENTPIDMAP': $map(['sourceid', 'uri']); break; default: parent::xmlSerializeValue($writer); } }