1 config.admin.inc config_import_full_form_submit(array &$form, array &$form_state)

Submit handler for config_import_full_form().

File

core/modules/config/config.admin.inc, line 244
Admin page callbacks for the Configuration Management module.

Code

function config_import_full_form_submit(array &$form, array &$form_state) {
  if ($fid = $form_state['values']['import_tarball']) {
    // Empty out the existing staging directory.
    $config_storage = config_get_config_storage('staging');
    $config_storage->deleteAll();

    // Convert the file URI to a file path that is readable by ArchiverTar.
    $file = file_load($fid);
    try {
      $config_storage->importArchive($file->uri);
    }
    catch (\ConfigStorageException $e) {
      form_set_error('import_tarball', t('Could not extract the contents of the tar file. The error message is "@message".', array('@message' => $e->getMessage())));
    }
    file_delete($file->fid);

    // Compare the files to see if any config actually differs.
    $config_statuses = array_filter(config_get_statuses());
    if (empty($config_statuses)) {
      $config_storage->deleteAll();
      backdrop_set_message(t('The uploaded configuration matches the current site configuration exactly. No changes were made.'), 'warning');
    }
    else {
      backdrop_set_message(t('Your configuration files were successfully uploaded. You may view the differences below. Import into your site by using the "Import all" button.'));
      $form_state['redirect'] = 'admin/config/development/configuration';
    }
  }
}