language_configuration_element_submit(&$form, FormStateInterface $form_state)
Submit handler for the forms that have a language_configuration element.
File
- core/modules/language/language.module, line 185
- Add language handling functionality to Drupal.
Code
function language_configuration_element_submit(&$form, FormStateInterface $form_state) { // Iterate through all the language_configuration elements and save their // values. // In case we are editing a bundle, we must check the new bundle name, // because e.g. hook_ENTITY_update fired before. if ($language = $form_state->get('language')) { foreach ($language as $element_name => $values) { $entity_type_id = $values['entity_type']; $bundle = $values['bundle']; $form_object = $form_state->getFormObject(); if ($form_object instanceof EntityFormInterface) { /** @var EntityFormInterface $form_object */ $entity = $form_object->getEntity(); if ($entity->getEntityType()->getBundleOf()) { $bundle = $entity->id(); $language[$element_name]['bundle'] = $bundle; } } $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle); $config->setDefaultLangcode($form_state->getValue(array($element_name, 'langcode'))); $config->setLanguageAlterable($form_state->getValue(array($element_name, 'language_alterable'))); $config->save(); // Set the form_state languaged with the updated bundle. $form_state->set('language', $language); } } }
Please login to continue.