diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc deleted file mode 100644 index a961286..0000000 --- a/core/modules/config/config.admin.inc +++ /dev/null @@ -1,167 +0,0 @@ -listAll(); - if (empty($source_list)) { - $form['no_changes'] = array( - '#markup' => t('There is no configuration to import.'), - ); - $form['actions']['#access'] = FALSE; - return $form; - } - - $config_comparer = new StorageComparerManifest(Drupal::service('config.storage.staging'), Drupal::service('config.storage')); - if (!$config_comparer->createChangelist()->hasChanges()) { - $form['no_changes'] = array( - '#markup' => t('There are no configuration changes.'), - ); - $form['actions']['#access'] = FALSE; - return $form; - } - else { - // Store the comparer for use in the submit. - $form_state['storage_comparer'] = $config_comparer; - } - - // Add the AJAX library to the form for dialog support. - $form['#attached']['library'][] = array('system', 'drupal.ajax'); - - foreach ($config_comparer->getChangelist() as $config_change_type => $config_files) { - if (empty($config_files)) { - continue; - } - - // @todo A table caption would be more appropriate, but does not have the - // visual importance of a heading. - $form[$config_change_type]['heading'] = array( - '#theme' => 'html_tag__h3', - '#tag' => 'h3', - ); - switch ($config_change_type) { - case 'create': - $form[$config_change_type]['heading']['#value'] = format_plural(count($config_files), '@count new', '@count new'); - break; - - case 'update': - $form[$config_change_type]['heading']['#value'] = format_plural(count($config_files), '@count changed', '@count changed'); - break; - - case 'delete': - $form[$config_change_type]['heading']['#value'] = format_plural(count($config_files), '@count removed', '@count removed'); - break; - } - $form[$config_change_type]['list'] = array( - '#theme' => 'table', - '#header' => array('Name', 'Operations'), - ); - - foreach ($config_files as $config_file) { - $links['view_diff'] = array( - 'title' => t('View differences'), - 'href' => 'admin/config/development/sync/diff/' . $config_file, - 'attributes' => array( - 'class' => array('use-ajax'), - 'data-accepts' => 'application/vnd.drupal-modal', - 'data-dialog-options' => json_encode(array( - 'width' => 700 - )), - ), - ); - $form[$config_change_type]['list']['#rows'][] = array( - 'name' => $config_file, - 'operations' => array( - 'data' => array( - '#type' => 'operations', - '#links' => $links, - ), - ), - ); - } - } -} - -/** - * Form constructor for configuration import form. - * - * @see config_admin_import_form_submit() - * @see config_import() - */ -function config_admin_import_form($form, &$form_state) { - // Retrieve a list of differences between last known state and active store. - $source_storage = drupal_container()->get('config.storage.staging'); - $target_storage = drupal_container()->get('config.storage'); - - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Import all'), - ); - - config_admin_sync_form($form, $form_state, $source_storage, $target_storage); - - return $form; -} - -/** - * Form submission handler for config_admin_import_form(). - */ -function config_admin_import_form_submit($form, &$form_state) { - $config_importer = new ConfigImporter( - $form_state['storage_comparer'], - Drupal::service('event_dispatcher'), - Drupal::service('config.factory'), - Drupal::entityManager(), - Drupal::lock() - ); - if ($config_importer->alreadyImporting()) { - drupal_set_message(t('Another request may be synchronizing configuration already.')); - } - else{ - try { - $config_importer->import(); - drupal_flush_all_caches(); - drupal_set_message(t('The configuration was imported successfully.')); - - // Once a sync completes, we empty the staging directory. This prevents - // changes from being accidentally overwritten by stray files getting - // imported later. - $source_storage = $config_importer->getStorageComparer()->getSourceStorage(); - foreach ($source_storage->listAll() as $name) { - $source_storage->delete($name); - } - } - catch (ConfigException $e) { - // Return a negative result for UI purposes. We do not differentiate between - // an actual synchronization error and a failed lock, because concurrent - // synchronizations are an edge-case happening only when multiple developers - // or site builders attempt to do it without coordinating. - watchdog_exception('config_import', $e); - drupal_set_message(t('The import failed due to an error. Any errors have been logged.'), 'error'); - } - } -} diff --git a/core/modules/config/config.module b/core/modules/config/config.module index 8bb9d21..6b5c48e 100644 --- a/core/modules/config/config.module +++ b/core/modules/config/config.module @@ -43,14 +43,11 @@ function config_menu() { $items['admin/config/development/sync'] = array( 'title' => 'Synchronize configuration', 'description' => 'Synchronize configuration changes.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('config_admin_import_form'), - 'access arguments' => array('synchronize configuration'), - 'file' => 'config.admin.inc', + 'route_name' => 'config_sync', ); $items['admin/config/development/sync/diff/%'] = array( 'title' => 'Configuration file diff', - 'description' => 'Diff between active and staged configuraiton.', + 'description' => 'Diff between active and staged configuration.', 'route_name' => 'config_diff', ); $items['admin/config/development/sync/import'] = array( diff --git a/core/modules/config/config.routing.yml b/core/modules/config/config.routing.yml index 505539d..d0bb2e7 100644 --- a/core/modules/config/config.routing.yml +++ b/core/modules/config/config.routing.yml @@ -4,3 +4,9 @@ config_diff: _content: '\Drupal\config\Controller\ConfigController::diff' requirements: _permission: 'synchronize configuration' +config_sync: + pattern: 'admin/config/development/sync' + defaults: + _form: '\Drupal\config\Form\ConfigSync' + requirements: + _permission: 'synchronize configuration'