Revert "Issue #2575843 by raman.b, ankithashetty, tassilogroeper, Hardik_Patel_12, smustgrave: Cleanup ContentTranslationHandler"

This reverts commit 0d720c3cc6.
merge-requests/3385/merge
Lauri Eskola 2023-02-16 12:02:48 +02:00
parent 70700fcc7d
commit 0da5ef42cc
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
1 changed files with 25 additions and 32 deletions

View File

@ -563,21 +563,13 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
* *
* @see \Drupal\content_translation\ContentTranslationHandler::entityFormAlter() * @see \Drupal\content_translation\ContentTranslationHandler::entityFormAlter()
*/ */
public function entityFormSharedElements(array $element, FormStateInterface $form_state, $form) { public function entityFormSharedElements($element, FormStateInterface $form_state, $form) {
static $ignored_types; static $ignored_types;
// @todo Find a more reliable way to determine if a form element concerns a // @todo Find a more reliable way to determine if a form element concerns a
// multilingual value. // multilingual value.
if (!isset($ignored_types)) { if (!isset($ignored_types)) {
$ignored_types = array_flip([ $ignored_types = array_flip(['actions', 'value', 'hidden', 'vertical_tabs', 'token', 'details', 'link']);
'actions',
'value',
'hidden',
'vertical_tabs',
'token',
'details',
'link',
]);
} }
/** @var \Drupal\Core\Entity\ContentEntityForm $form_object */ /** @var \Drupal\Core\Entity\ContentEntityForm $form_object */
@ -598,14 +590,13 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
if (!isset($element[$key]['#type'])) { if (!isset($element[$key]['#type'])) {
$this->entityFormSharedElements($element[$key], $form_state, $form); $this->entityFormSharedElements($element[$key], $form_state, $form);
} }
else {
// Ignore non-widget form elements. // Ignore non-widget form elements.
if (isset($ignored_types[$element[$key]['#type']])) { if (isset($ignored_types[$element[$key]['#type']])) {
continue; continue;
} }
// Elements are considered to be non-multilingual by default. // Elements are considered to be non multilingual by default.
if (!empty($element[$key]['#multilingual'])) { if (empty($element[$key]['#multilingual'])) {
continue;
}
// If we are displaying a multilingual entity form we need to provide // If we are displaying a multilingual entity form we need to provide
// translatability clues, otherwise the non-multilingual form elements // translatability clues, otherwise the non-multilingual form elements
// should be hidden. // should be hidden.
@ -623,6 +614,8 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
$element[$key]['#access'] = FALSE; $element[$key]['#access'] = FALSE;
} }
} }
}
}
if ($display_warning && !$form_state->isSubmitted() && !$form_state->isRebuilding()) { if ($display_warning && !$form_state->isSubmitted() && !$form_state->isRebuilding()) {
$url = $entity->getUntranslated()->toUrl('edit-form')->toString(); $url = $entity->getUntranslated()->toUrl('edit-form')->toString();