function content_translation_enable_widget

content_translation_enable_widget($entity_type, $bundle, array &$form, FormStateInterface $form_state)

Returns a widget to enable content translation per entity bundle.

Backward compatibility layer to support entities not using the language configuration form element.

@todo Remove once all core entities have language configuration.

Parameters

string $entity_type: The type of the entity being configured for translation.

string $bundle: The bundle of the entity being configured for translation.

array $form: The configuration form array.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

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

Code

function content_translation_enable_widget($entity_type, $bundle, array &$form, FormStateInterface $form_state) {
  $key = $form_state->get(['content_translation', 'key']);
  $context = $form_state->get(['language', $key]) ? : [];
  $context += ['entity_type' => $entity_type, 'bundle' => $bundle];
  $form_state->set(['language', $key], $context);
  $element = content_translation_language_configuration_element_process(array('#name' => $key), $form_state, $form);
  unset($element['content_translation']['#element_validate']);
  return $element;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!content_translation!content_translation.module/function/content_translation_enable_widget/8.1.x