function configuration_download_config in Configuration Management 7
Download the entire configuration packaged up into zip file
2 calls to configuration_download_config()
- configuration_download_config_submit in ./
configuration.admin.inc - Submit handler for downloading diff.
- configuration_migrate_form_submit in ./
configuration.admin.inc - Submit handler for downloading configs.
File
- ./
configuration.admin.inc, line 936
Code
function configuration_download_config($configs = NULL) {
module_load_include('inc', 'configuration', 'configuration.export');
if ($configs) {
configuration_include();
// Only set the configurations that were checked to be passed to the
// configuration_populate function.
foreach ($configs as $component => $config) {
foreach ($config as $name => $on) {
if ($on) {
if (!empty($all_config[$component][$name])) {
$c[$component][$name] = $all_config[$component][$name];
}
else {
$function = "configuration_hash_{$component}";
$hash = $function($name);
$c[$component][$name]['hash'] = $hash;
$c[$component][$name]['status'] = CONFIGURATION_IN_SYNC;
$c[$component][$name]['parent'] = '';
}
}
}
}
$config = $c;
}
else {
$config = configuration_get_configuration();
}
$config_populate = configuration_populate_sanitize($config);
// Generate populated feature
$module_name = 'configuration';
$export = configuration_populate($config_populate, array());
// Configs passed in by migrate function
if ($configs) {
// Check if there is dependencies to export.
if (!empty($export['configuration_dependency'])) {
foreach ($export['configuration_dependency']['configuration'] as $component => $config) {
foreach ($config as $name => $parent) {
$c[$component][$name]['status'] = CONFIGURATION_DATASTORE_ONLY;
$c[$component][$name]['parent'] = $parent;
}
}
}
configuration_write_export_file($c, "temporary://config.export");
}
// Generate download
if ($files = configuration_export_render($export, $module_name, TRUE)) {
$filename = (!empty($export['version']) ? "{$module_name}-{$export['version']}" : $module_name) . '.tar';
// Clear out output buffer to remove any garbage from tar output.
if (ob_get_level()) {
ob_end_clean();
}
drupal_add_http_header('Content-type', 'application/x-tar');
drupal_add_http_header('Content-Disposition', 'attachment; filename="' . $filename . '"');
drupal_send_headers();
$tar = array();
$filenames = array();
foreach ($files as $extension => $file_contents) {
if (!in_array($extension, array(
'module',
'info',
))) {
$extension .= '.inc';
}
$filenames[] = "{$module_name}.{$extension}";
print configuration_tar_create("{$module_name}/{$extension}", $file_contents);
}
$contents = file_get_contents("temporary://config.export");
print configuration_tar_create("{$module_name}/config.export", $contents);
unset($contents);
print pack("a1024", "");
exit;
}
}