function ContentLanguageSettingsForm::submitForm

Same name in other branches
  1. 9 core/modules/language/src/Form/ContentLanguageSettingsForm.php \Drupal\language\Form\ContentLanguageSettingsForm::submitForm()
  2. 10 core/modules/language/src/Form/ContentLanguageSettingsForm.php \Drupal\language\Form\ContentLanguageSettingsForm::submitForm()
  3. 11.x core/modules/language/src/Form/ContentLanguageSettingsForm.php \Drupal\language\Form\ContentLanguageSettingsForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/language/src/Form/ContentLanguageSettingsForm.php, line 177

Class

ContentLanguageSettingsForm
Configure the content language settings for this site.

Namespace

Drupal\language\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $entity_types = $form_state->getValue('entity_types');
    foreach ($form_state->getValue('settings') as $entity_type => $entity_settings) {
        foreach ($entity_settings as $bundle => $bundle_settings) {
            $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type, $bundle);
            if (empty($entity_types[$entity_type])) {
                $bundle_settings['settings']['language']['language_alterable'] = FALSE;
            }
            $config->setDefaultLangcode($bundle_settings['settings']['language']['langcode'])
                ->setLanguageAlterable($bundle_settings['settings']['language']['language_alterable'])
                ->save();
        }
    }
    $this->messenger()
        ->addStatus($this->t('Settings successfully updated.'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.