You are here

public function ConfigSyncImportForm::submitForm in Configuration Synchronizer 8.2

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 ConfigSync::submitForm

File

src/Form/ConfigSyncImportForm.php, line 391

Class

ConfigSyncImportForm

Namespace

Drupal\config_sync\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Save the selected update_mode.
  $this->state
    ->set('config_sync.update_mode', (int) $form_state
    ->getValue('update_mode'));

  // Save data on selected modules and themes to the system state.
  $plugin_data = [];
  foreach ([
    'module',
    'theme',
  ] as $type) {
    if ($names = $form_state
      ->getValue($type)) {

      // Convert data to boolean values.
      array_walk($names, function ($value, $key) use ($type, &$plugin_data) {
        $value = (bool) $value;
        $plugin_data[$type][$key]['status'] = $value;
      });
    }
  }
  $this->state
    ->set('config_sync.plugins', $plugin_data);
  $this->state
    ->set('config_sync.plugins_previous', $plugin_data);
  $this->configFilterManager
    ->clearCachedDefinitions();
  parent::submitForm($form, $form_state);
}