Form submission handler for config_admin_import_form().
function config_admin_import_form_submit($form, &$form_state) {
if (!lock()
->lockMayBeAvailable(CONFIG_IMPORT_LOCK)) {
drupal_set_message(t('Another request may be synchronizing configuration already.'));
}
else {
if (config_import()) {
// Once a sync completes, we empty the staging directory. This prevents
// changes from being accidentally overwritten by stray files getting
// imported later.
$source_storage = drupal_container()
->get('config.storage.staging');
foreach ($source_storage
->listAll() as $name) {
$source_storage
->delete($name);
}
drupal_flush_all_caches();
drupal_set_message(t('The configuration was imported successfully.'));
}
else {
drupal_set_message(t('The import failed due to an error. Any errors have been logged.'), 'error');
}
}
}