ConfigSync::submitForm

public ConfigSync::submitForm(array &$form, FormStateInterface $form_state)

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

core/modules/config/src/Form/ConfigSync.php, line 318

Class

ConfigSync
Construct the storage changes in a configuration synchronization form.

Namespace

Drupal\config\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config_importer = new ConfigImporter(
  $form_state->get('storage_comparer'), 
  $this->eventDispatcher, 
  $this->configManager, 
  $this->lock, 
  $this->typedConfigManager, 
  $this->moduleHandler, 
  $this->moduleInstaller, 
  $this->themeHandler, 
  $this->getStringTranslation()
  );
  if ($config_importer->alreadyImporting()) {
    drupal_set_message($this->t('Another request may be synchronizing configuration already.'));
  }
  else {
    try {
      $sync_steps = $config_importer->initialize();
      $batch = array(
        'operations' => array(),
        'finished' => array(get_class($this), 'finishBatch'),
        'title' => t('Synchronizing configuration'),
        'init_message' => t('Starting configuration synchronization.'),
        'progress_message' => t('Completed step @current of @total.'),
        'error_message' => t('Configuration synchronization has encountered an error.'),
        'file' => __DIR__ . '/../../config.admin.inc',
      );
      foreach ($sync_steps as $sync_step) {
        $batch['operations'][] = array(array(get_class($this), 'processBatch'), array($config_importer, $sync_step));
      }

      batch_set($batch);
    }
    catch (ConfigImporterException $e) {
      // There are validation errors.
      drupal_set_message($this->t('The configuration cannot be imported because it failed validation for the following reasons:'), 'error');
      foreach ($config_importer->getErrors() as $message) {
        drupal_set_message($message, 'error');
      }
    }
  }
}
doc_Drupal
2016-10-29 08:54:36
Comments
Leave a Comment

Please login to continue.