public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
{
$doc = new DOMDocument('1.0', 'utf-8');
$root = $doc->createElement('related-objects');
$doc->appendChild($root);
$relationList = $doc->createElement('relation-list');
$data = $this->getRelationXmlHashFromDB($value->data['destinationContentIds']);
$priority = 0;
foreach ($value->data['destinationContentIds'] as $id) {
if (!isset($data[$id][0])) {
// Ignore deleted content items (we can't throw as it would block ContentService->createContentDraft())
continue;
}
$row = $data[$id][0];
$row['ezcontentobject_id'] = $id;
$row['priority'] = $priority += 1;
$relationItem = $doc->createElement('relation-item');
foreach (self::dbAttributeMap() as $domAttrKey => $propertyKey) {
if (!isset($row[$propertyKey])) {
// left join data missing, ignore the given attribute (content in trash missing location)
continue;
}
$relationItem->setAttribute($domAttrKey, $row[$propertyKey]);
}
$relationList->appendChild($relationItem);
unset($relationItem);
}
$root->appendChild($relationList);
$doc->appendChild($root);
$storageFieldValue->dataText = $doc->saveXML();
}