Return the file content for the job data.
$job: The translation job object to be exported.
array $conditions: (optional) An array containing list of conditions.
String with the file content.
Overrides FormatInterface::export
public function export(JobInterface $job, $conditions = array()) {
$this->job = $job;
$this
->openMemory();
$this
->setIndent(TRUE);
$this
->setIndentString(' ');
$this
->startDocument('1.0', 'UTF-8');
// Root element with schema definition.
$this
->startElement('xliff');
$this
->writeAttribute('version', '1.2');
$this
->writeAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');
$this
->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this
->writeAttribute('xsi:schemaLocation', 'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd');
// File element.
$this
->startElement('file');
$this
->writeAttribute('original', 'xliff-core-1.2-strict.xsd');
$this
->writeAttribute('source-language', $job
->getRemoteSourceLanguage());
$this
->writeAttribute('target-language', $job
->getRemoteTargetLanguage());
$this
->writeAttribute('datatype', 'plaintext');
// Date needs to be in ISO-8601 UTC
$this
->writeAttribute('date', date('Y-m-d\\Th:m:i\\Z'));
$this
->startElement('header');
$this
->startElement('phase-group');
$this
->startElement('phase');
$this
->writeAttribute('tool-id', 'tmgmt');
$this
->writeAttribute('phase-name', 'extraction');
$this
->writeAttribute('process-name', 'extraction');
$this
->writeAttribute('job-id', $job
->id());
$this
->endElement();
$this
->endElement();
$this
->startElement('tool');
$this
->writeAttribute('tool-id', 'tmgmt');
$this
->writeAttribute('tool-name', 'Drupal Translation Management Tools');
$this
->endElement();
$this
->endElement();
$this
->startElement('body');
foreach ($job
->getItems($conditions) as $item) {
$this
->addItem($item);
}
// End the body, file and xliff tags.
$this
->endElement();
$this
->endElement();
$this
->endElement();
$this
->endDocument();
return $this
->outputMemory();
}