ContentTranslationHandler::entityFormSourceChange

public ContentTranslationHandler::entityFormSourceChange($form, FormStateInterface $form_state)

Form submission handler for ContentTranslationHandler::entityFormAlter().

Takes care of the source language change.

File

core/modules/content_translation/src/ContentTranslationHandler.php, line 644

Class

ContentTranslationHandler
Base class for content translation handlers.

Namespace

Drupal\content_translation

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public function entityFormSourceChange($form, FormStateInterface $form_state) {
  $form_object = $form_state->getFormObject();
  $entity = $form_object->getEntity();
  $source = $form_state->getValue(array('source_langcode', 'source'));
 
  $entity_type_id = $entity->getEntityTypeId();
  $form_state->setRedirect("entity.$entity_type_id.content_translation_add", array(
    $entity_type_id => $entity->id(),
    'source' => $source,
    'target' => $form_object->getFormLangcode($form_state),
  ));
  $languages = $this->languageManager->getLanguages();
  drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->getName())));
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.