protected function LingotekSettingsTabPreferencesForm::saveShowLanguageFields in Lingotek Translation 3.3.x
Same name and namespace in other branches
- 8 src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 8.2 src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 4.0.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.0.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.1.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.2.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.4.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.5.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.6.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.7.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- 3.8.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
1 call to LingotekSettingsTabPreferencesForm::saveShowLanguageFields()
- LingotekSettingsTabPreferencesForm::submitForm in src/
Form/ LingotekSettingsTabPreferencesForm.php - Form submission handler.
File
- src/
Form/ LingotekSettingsTabPreferencesForm.php, line 310
Class
- LingotekSettingsTabPreferencesForm
- Configure Lingotek
Namespace
Drupal\lingotek\FormCode
protected function saveShowLanguageFields($form_values) {
$config = \Drupal::configFactory()
->getEditable('lingotek.settings');
// Only save if there's a change to the show_language_labels choice
if ($config
->get('preference.show_language_labels') != $form_values['show_language_labels']) {
$bundles = \Drupal::service('entity_type.bundle.info')
->getBundleInfo('node');
foreach ($bundles as $bundle_id => $bundle) {
if ($bundle['translatable']) {
$field_definitions = \Drupal::service('entity_field.manager')
->getFieldDefinitions('node', $bundle_id);
$langcode = $field_definitions['langcode'];
$display = $this->entityTypeManager
->getStorage('entity_view_display')
->load('node.' . $bundle_id . '.default');
if ($form_values['show_language_labels']) {
$component_values = [
'type' => 'language',
'weight' => 0,
'settings' => [],
'third_party_settings' => [],
// Can be above, inline, hidden, or visually_hidden (These are hard coded in core)
'label' => 'above',
];
$display
->setComponent('langcode', $component_values);
}
else {
$display
->removeComponent('langcode');
}
$display
->save();
}
}
}
$config
->set('preference.show_language_labels', $form_values['show_language_labels'] ? TRUE : FALSE);
$config
->save();
}