diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 10f6a92..c1ea11a 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -338,16 +338,18 @@ function _content_translation_menu_strip_loaders($path) { * Implements hook_entity_prepare_form(). */ function content_translation_entity_prepare_form(EntityInterface $entity, $form_display, $operation, array &$form_state) { - $languages = language_list(); - $source = Drupal::request()->get('content_translation_source'); - $target = Drupal::request()->get('content_translation_target'); - content_translation_prepare_translation_form($entity, isset($languages[$source]) ? $source : FALSE, isset($languages[$target]) ? $target : NULL, $form_state); + if ($entity instanceof ContentEntityInterface) { + $languages = language_list(); + $source = Drupal::request()->get('content_translation_source'); + $target = Drupal::request()->get('content_translation_target'); + content_translation_prepare_translation_form($entity, isset($languages[$source]) ? $source : FALSE, isset($languages[$target]) ? $target : NULL, $form_state); + } } /** * Prepares the entity and the form state to display a translation form. * - * @param EntityInterface $entity + * @param ContentEntityInterface $entity * The entity being translated. * @param string $source * The language code to be used as source. @@ -356,7 +358,7 @@ function content_translation_entity_prepare_form(EntityInterface $entity, $form_ * @param array $form_state * An associative array representing the state of the form. */ -function content_translation_prepare_translation_form(EntityInterface $entity, $source, $target, array &$form_state) { +function content_translation_prepare_translation_form(ContentEntityInterface $entity, $source, $target, array &$form_state) { if (empty($form_state['content_translation']['prepared']) && $entity->isTranslatable() && content_translation_access($entity, $source ? 'create' : 'update')) { // Avoid preparing the entity form twice. $form_state['content_translation']['prepared'] = TRUE;