LocaleSettingsForm::submitForm

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

File

core/modules/locale/src/Form/LocaleSettingsForm.php, line 101

Class

LocaleSettingsForm
Configure locale settings for this site.

Namespace

Drupal\locale\Form

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state->getValues();
 
  $config = $this->config('locale.settings');
  $config->set('translation.update_interval_days', $values['update_interval_days'])->save();
  $config->set('translation.use_source', $values['use_source'])->save();
 
  switch ($values['overwrite']) {
    case LOCALE_TRANSLATION_OVERWRITE_ALL:
      $config
      ->set('translation.overwrite_customized', TRUE)
        ->set('translation.overwrite_not_customized', TRUE)
        ->save();
      break;
 
    case LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED:
      $config
      ->set('translation.overwrite_customized', FALSE)
        ->set('translation.overwrite_not_customized', TRUE)
        ->save();
      break;
 
    case LOCALE_TRANSLATION_OVERWRITE_NONE:
      $config
      ->set('translation.overwrite_customized', FALSE)
        ->set('translation.overwrite_not_customized', FALSE)
        ->save();
      break;
  }
 
  // Invalidate the cached translation status when the configuration setting
  // of 'use_source' changes.
  if ($form['use_source']['#default_value'] != $form_state->getValue('use_source')) {
    locale_translation_clear_status();
  }
 
  parent::submitForm($form, $form_state);
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.