Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContentTranslationHooks.php

function ContentTranslationHooks::entityBundleInfoAlter

Implements hook_entity_bundle_info_alter().

File

core/modules/content_translation/src/Hook/ContentTranslationHooks.php, line 219

Class

ContentTranslationHooks
Hook implementations for content_translation.

Namespace

Drupal\content_translation\Hook

Code

public function entityBundleInfoAlter(&$bundles) : void {
    
    /** @var \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager */
    $content_translation_manager = \Drupal::service('content_translation.manager');
    foreach ($bundles as $entity_type_id => &$info) {
        foreach ($info as $bundle => &$bundle_info) {
            $bundle_info['translatable'] = $content_translation_manager->isEnabled($entity_type_id, $bundle);
            if ($bundle_info['translatable'] && $content_translation_manager instanceof BundleTranslationSettingsInterface) {
                $settings = $content_translation_manager->getBundleTranslationSettings($entity_type_id, $bundle);
                // If pending revision support is enabled for this bundle, we need to
                // hide untranslatable field widgets, otherwise changes in pending
                // revisions might be overridden by changes in later default revisions.
                $bundle_info['untranslatable_fields.default_translation_affected'] = !empty($settings['untranslatable_fields_hide']) || ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id, $bundle);
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal