function configuration_write_exports in Configuration Management 7
Writes configurations to disk.
Parameters
$components An array of components to write to file.:
$exclude An array $component => $identifier of what to exclude from export.:
Return value
Returns TRUE if write was sucessful
2 calls to configuration_write_exports()
- configuration_delete_multiple in ./
configuration.module - Delete a specific configuration from being tracked.
- configuration_save in ./
configuration.module - Save changes to track configuration.
File
- ./
configuration.export.inc, line 842
Code
function configuration_write_exports($components = NULL, $exclude = array()) {
$config = configuration_get_configuration();
try {
// Check files in the config directory and ensure we won't overwrite
// new configs before writing to file.
if (configuration_check_changed(CONFIGURATION_DATASTORE_ONLY, $components)) {
$config_populate = configuration_populate_sanitize($config);
$export = configuration_populate($config_populate, array());
// Track dependencies on config_export table
_configuration_track_dependencies($export);
// @see configuration_delete_multiple().
foreach ($exclude as $identifier => $component) {
unset($export['configuration'][$component][$identifier]);
}
// Remove any components that were not checked from being exported
foreach (array_keys($export['configuration']) as $export_component) {
if (!in_array($export_component, $components)) {
unset($export['configuration'][$export_component]);
}
}
// Write files to filesystem
if ($files = configuration_export_render($export, TRUE)) {
$filenames = array();
foreach ($files as $filename => $file_contents) {
if (!in_array($filename, array(
'module',
'info',
))) {
$filename .= '.inc';
}
file_put_contents('config://' . $filename, $file_contents);
drupal_set_message(t('Wrote %file to filesystem', array(
'%file' => $filename,
)));
}
}
configuration_write_export_file();
}
else {
// Can't write to datastore.
return FALSE;
}
} catch (Exception $e) {
watchdog_exception('configuration', $e);
throw $e;
}
return TRUE;
}