public static function createTemplateXmlForExport($theme)
{
$charset = BackendModel::getContainer()->getParameter('kernel.charset');
// build xml
$xml = new \DOMDocument('1.0', $charset);
$xml->preserveWhiteSpace = false;
$xml->formatOutput = true;
$root = $xml->createElement('templates');
$xml->appendChild($root);
$db = BackendModel::getContainer()->get('database');
$records = $db->getRecords(self::QRY_BROWSE_TEMPLATES, array($theme));
foreach ($records as $row) {
$template = self::getTemplate($row['id']);
$data = unserialize($template['data']);
$templateElement = $xml->createElement('template');
$templateElement->setAttribute('label', $template['label']);
$templateElement->setAttribute('path', $template['path']);
$root->appendChild($templateElement);
$positionsElement = $xml->createElement('positions');
$templateElement->appendChild($positionsElement);
foreach ($data['names'] as $name) {
$positionElement = $xml->createElement('position');
$positionElement->setAttribute('name', $name);
$positionsElement->appendChild($positionElement);
}
$formatElement = $xml->createElement('format');
$templateElement->appendChild($formatElement);
$formatElement->nodeValue = $data['format'];
}
return $xml->saveXML();
}