private function exportDataModel($dataTypes = 'all')
{
// If all data types should be exported, get all the available data types that can be exported.
if (is_array($dataTypes)) {
// Validate that each data type specified to be exported is reconized.
foreach ($dataTypes as $dataType) {
if (!in_array($dataType, $this->exportableDataTypes)) {
$errorMessage = 'Invalid export type "' . $dataType . '". Accepted types are ' . implode(', ', $this->exportableDataTypes);
throw new Exception($errorMessage);
}
}
} else {
$dataTypes = $this->exportableDataTypes;
}
$categoryGroups = Craft::app()->categories->getAllGroups();
$tagGroups = Craft::app()->tags->getAllTagGroups();
$export = [];
if (in_array('locales', $dataTypes)) {
$export['locales'] = Craft::app()->schematic_locales->export();
}
if (in_array('assetSources', $dataTypes)) {
$export['assetSources'] = Craft::app()->schematic_assetSources->export();
}
if (in_array('fields', $dataTypes)) {
$fieldGroups = Craft::app()->fields->getAllGroups();
$export['fields'] = Craft::app()->schematic_fields->export($fieldGroups);
}
if (in_array('plugins', $dataTypes)) {
$export['plugins'] = Craft::app()->schematic_plugins->export();
}
if (in_array('sections', $dataTypes)) {
$sections = Craft::app()->sections->getAllSections();
$export['sections'] = Craft::app()->schematic_sections->export($sections);
}
if (in_array('globalSets', $dataTypes)) {
$globals = Craft::app()->globals->getAllSets();
$export['globalSets'] = Craft::app()->schematic_globalSets->export($globals);
}
if (in_array('userGroups', $dataTypes)) {
$userGroups = Craft::app()->userGroups->getAllGroups();
$export['userGroups'] = Craft::app()->schematic_userGroups->export($userGroups);
}
if (in_array('users', $dataTypes)) {
$export['users'] = Craft::app()->schematic_users->export();
}
if (in_array('categoryGroups', $dataTypes)) {
$export['categoryGroups'] = Craft::app()->schematic_categoryGroups->export($categoryGroups);
}
if (in_array('tagGroups', $dataTypes)) {
$export['tagGroups'] = Craft::app()->schematic_tagGroups->export($tagGroups);
}
// Element index settings are supported from Craft 2.5
if (in_array('elementIndexSettings', $dataTypes) && version_compare(CRAFT_VERSION, '2.5', '>=')) {
$export['elementIndexSettings'] = Craft::app()->schematic_elementIndexSettings->export();
}
if (in_array('pluginData', $dataTypes)) {
$export['pluginData'] = [];
$services = Craft::app()->plugins->call('registerMigrationService');
$this->doExport($services, $export['pluginData']);
}
return $export;
}