content_translation_language_configuration_element_submit

content_translation_language_configuration_element_submit(array $form, FormStateInterface $form_state)

Form submission handler for element added with content_translation_language_configuration_element_process().

Stores the content translation settings.

See also

content_translation_language_configuration_element_validate()

File

core/modules/content_translation/content_translation.module, line 529
Allows entities to be translated into different languages.

Code

1
2
3
4
5
6
7
8
9
10
11
function content_translation_language_configuration_element_submit(array $form, FormStateInterface $form_state) {
  $key = $form_state->get(['content_translation', 'key']);
  $context = $form_state->get(['language', $key]);
  $enabled = $form_state->getValue(array($key, 'content_translation'));
 
  if (\Drupal::service('content_translation.manager')->isEnabled($context['entity_type'], $context['bundle']) != $enabled) {
    \Drupal::service('content_translation.manager')->setEnabled($context['entity_type'], $context['bundle'], $enabled);
    \Drupal::entityManager()->clearCachedDefinitions();
    \Drupal::service('router.builder')->setRebuildNeeded();
  }
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.