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) {
    
    /** @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);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.