function ContentTranslationEnableTranslationPerBundle::configElementSubmit

Same name and namespace in other branches
  1. main core/modules/content_translation/src/ContentTranslationEnableTranslationPerBundle.php \Drupal\content_translation\ContentTranslationEnableTranslationPerBundle::configElementSubmit()

Provides a submit callback for the language enable/disable element.

Parameters

array $form: The form render array.

\Drupal\Core\Form\FormStateInterface $formState: The form current state.

File

core/modules/content_translation/src/ContentTranslationEnableTranslationPerBundle.php, line 142

Class

ContentTranslationEnableTranslationPerBundle
Provides a widget to enable content translation per entity bundle.

Namespace

Drupal\content_translation

Code

public function configElementSubmit(array $form, FormStateInterface $formState) : void {
  $key = $formState->get([
    'content_translation',
    'key',
  ]);
  $context = $formState->get([
    'language',
    $key,
  ]);
  $enabled = $formState->getValue([
    $key,
    'content_translation',
  ]);
  if ($this->contentTranslationManager
    ->isEnabled($context['entity_type'], $context['bundle']) != $enabled) {
    $this->contentTranslationManager
      ->setEnabled($context['entity_type'], $context['bundle'], $enabled);
    $this->routeBuilder
      ->setRebuildNeeded();
  }
}

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