You are here

public function SettingsForm::submitForm in Replication 8

Same name and namespace in other branches
  1. 8.2 src/Form/SettingsForm.php \Drupal\replication\Form\SettingsForm::submitForm()

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

File

src/Form/SettingsForm.php, line 158

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\replication\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $config = $this
    ->config('replication.settings');
  $mapping_type = $form_state
    ->getValue('mapping_type');
  switch ($mapping_type) {
    case 'uid':
      $uid = $form_state
        ->getValue('uid');
      break;
    case 'anonymous':
      $uid = 0;
      break;
    case 'uid_1':
      $uid = 1;
      break;
    default:
      $uid = NULL;
  }
  $changes_limit = $form_state
    ->getValue('changes_limit');
  $bulk_docs_limit = $form_state
    ->getValue('bulk_docs_limit');
  $replication_execution_limit = $form_state
    ->getValue('replication_execution_limit');
  $verbose_logging = (bool) $form_state
    ->getValue('verbose_logging');
  $config
    ->set('mapping_type', $mapping_type)
    ->set('changes_limit', $changes_limit)
    ->set('bulk_docs_limit', $bulk_docs_limit)
    ->set('replication_execution_limit', $replication_execution_limit)
    ->set('verbose_logging', $verbose_logging)
    ->set('uid', trim($uid))
    ->save();
}