X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_translation%2Fcontent_translation.admin.inc;fp=web%2Fcore%2Fmodules%2Fcontent_translation%2Fcontent_translation.admin.inc;h=f7d5a0d21d0c42d14e55f872ed52538778c7ae87;hp=bf33ba0af05d5f83baffe3f695da994b27f97b44;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/content_translation/content_translation.admin.inc b/web/core/modules/content_translation/content_translation.admin.inc index bf33ba0af..f7d5a0d21 100644 --- a/web/core/modules/content_translation/content_translation.admin.inc +++ b/web/core/modules/content_translation/content_translation.admin.inc @@ -5,6 +5,8 @@ * The content translation administration forms. */ +use Drupal\content_translation\BundleTranslationSettingsInterface; +use Drupal\content_translation\ContentTranslationManager; use Drupal\Core\Config\Entity\ThirdPartySettingsInterface; use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface; @@ -83,6 +85,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ return; } + /** @var \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager */ $content_translation_manager = \Drupal::service('content_translation.manager'); $default = $form['entity_types']['#default_value']; foreach ($default as $entity_type_id => $enabled) { @@ -110,6 +113,26 @@ function _content_translation_form_language_content_settings_form_alter(array &$ continue; } + // Displayed the "shared fields widgets" toggle. + if ($content_translation_manager instanceof BundleTranslationSettingsInterface) { + $settings = $content_translation_manager->getBundleTranslationSettings($entity_type_id, $bundle); + $force_hidden = ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id, $bundle); + $form['settings'][$entity_type_id][$bundle]['settings']['content_translation']['untranslatable_fields_hide'] = [ + '#type' => 'checkbox', + '#title' => t('Hide non translatable fields on translation forms'), + '#default_value' => $force_hidden || !empty($settings['untranslatable_fields_hide']), + '#disabled' => $force_hidden, + '#description' => $force_hidden ? t('Moderated content requires non-translatable fields to be edited in the original language form.') : '', + '#states' => [ + 'visible' => [ + ':input[name="settings[' . $entity_type_id . '][' . $bundle . '][translatable]"]' => [ + 'checked' => TRUE, + ], + ], + ], + ]; + } + $fields = $entity_manager->getFieldDefinitions($entity_type_id, $bundle); if ($fields) { foreach ($fields as $field_name => $definition) { @@ -317,6 +340,8 @@ function content_translation_form_language_content_settings_validate(array $form * @see content_translation_admin_settings_form_validate() */ function content_translation_form_language_content_settings_submit(array $form, FormStateInterface $form_state) { + /** @var \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager */ + $content_translation_manager = \Drupal::service('content_translation.manager'); $entity_types = $form_state->getValue('entity_types'); $settings = &$form_state->getValue('settings'); @@ -347,7 +372,12 @@ function content_translation_form_language_content_settings_submit(array $form, } if (isset($bundle_settings['translatable'])) { // Store whether a bundle has translation enabled or not. - \Drupal::service('content_translation.manager')->setEnabled($entity_type_id, $bundle, $bundle_settings['translatable']); + $content_translation_manager->setEnabled($entity_type_id, $bundle, $bundle_settings['translatable']); + + // Store any other bundle settings. + if ($content_translation_manager instanceof BundleTranslationSettingsInterface) { + $content_translation_manager->setBundleTranslationSettings($entity_type_id, $bundle, $bundle_settings['settings']['content_translation']); + } // Save translation_sync settings. if (!empty($bundle_settings['columns'])) { @@ -367,8 +397,8 @@ function content_translation_form_language_content_settings_submit(array $form, } } } + // Ensure entity and menu router information are correctly rebuilt. \Drupal::entityManager()->clearCachedDefinitions(); \Drupal::service('router.builder')->setRebuildNeeded(); - }