public function import($content)
{
try {
$xml = $this->loadXml($content);
} catch (Exception $e) {
return false;
}
$orders = $this->getOrders($xml);
ksort($orders);
$documentTypes = array();
$errors = array();
$ids = array('datatypes' => array(), 'views' => array(), 'layouts' => array(), 'scripts' => array(), 'document_types' => array(), 'documents' => array(), 'properties' => array());
foreach ($orders as $children) {
switch ($children['name']) {
case 'datatypes':
$this->importDatatypes($ids, $errors, $children);
break;
case 'document_types':
$documentTypes = $this->importDocumentTypes($ids, $errors, $children);
break;
case 'documents':
$this->importDocuments($ids, $errors, $children);
break;
case 'views':
case 'layouts':
case 'scripts':
default:
$this->importTemplates($ids, $errors, $children);
break;
}
}
//must insert dependencies at the end
$this->insertDependencies($ids, $errors, $documentTypes);
if (!empty($errors)) {
return $errors;
}
return true;
}