You are here

public function SettingsForm::submitForm in General Data Protection Regulation 8

Same name and namespace in other branches
  1. 8.2 modules/gdpr_dump/src/Form/SettingsForm.php \Drupal\gdpr_dump\Form\SettingsForm::submitForm()
  2. 3.0.x modules/gdpr_dump/src/Form/SettingsForm.php \Drupal\gdpr_dump\Form\SettingsForm::submitForm()

Throws

\Drupal\Core\Config\ConfigValueException

Overrides ConfigFormBase::submitForm

File

modules/gdpr_dump/src/Form/SettingsForm.php, line 251

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\gdpr_dump\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->hasValue('tables')) {
    $mapping = [];

    /** @var array $tables */
    $tables = $form_state
      ->getValue('tables', []);
    $emptyTables = [];
    foreach ($tables as $table => $row) {
      if ($row['empty_table']) {
        $emptyTables[$table] = 1;
      }
      foreach ($row['columns'] as $name => $data) {
        if (!empty($data['option']) && $data['option'] !== self::GDPR_DUMP_NO_PLUGIN_KEY) {
          $mapping[$table][$name] = $data['option'];
        }
      }
    }
    $config = $this->configFactory
      ->getEditable(self::GDPR_DUMP_CONF_KEY);
    $config
      ->set('mapping', $mapping)
      ->save();
    $config
      ->set('empty_tables', $emptyTables)
      ->save();
  }
  parent::submitForm($form, $form_state);
}