private function serializeXML(\caption_record $caption, $includeBusinessFields) { $dom_doc = new \DOMDocument('1.0', 'UTF-8'); $dom_doc->formatOutput = true; $dom_doc->standalone = true; $record = $dom_doc->createElement('record'); $record->setAttribute('record_id', $caption->get_record()->get_record_id()); $dom_doc->appendChild($record); $description = $dom_doc->createElement('description'); $record->appendChild($description); foreach ($caption->get_fields([], $includeBusinessFields) as $field) { $values = $field->get_values(); foreach ($values as $value) { $elem = $dom_doc->createElement($field->get_name()); $elem->appendChild($dom_doc->createTextNode($this->sanitizeSerializedValue($value->getValue()))); $elem->setAttribute('meta_id', $value->getId()); $elem->setAttribute('meta_struct_id', $field->get_meta_struct_id()); $description->appendChild($elem); } } $doc = $dom_doc->createElement('doc'); $tc_datas = $caption->get_record()->get_technical_infos()->getValues(); foreach ($tc_datas as $key => $data) { $doc->setAttribute($key, $data); } $record->appendChild($doc); return $dom_doc->saveXML(); }
/** * List all field about a specified caption * * @param caption_record $caption * * @return array */ private function list_record_caption(\caption_record $caption) { $ret = []; foreach ($caption->get_fields() as $field) { foreach ($field->get_values() as $value) { $ret[] = $this->list_record_caption_field($value, $field); } } return $ret; }