function ContentTranslationHooks::entityExtraFieldInfo

Implements hook_entity_extra_field_info().

File

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

Class

ContentTranslationHooks
Hook implementations for content_translation.

Namespace

Drupal\content_translation\Hook

Code

public function entityExtraFieldInfo() {
    $extra = [];
    $bundle_info_service = \Drupal::service('entity_type.bundle.info');
    foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type => $info) {
        foreach ($bundle_info_service->getBundleInfo($entity_type) as $bundle => $bundle_info) {
            if (\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle)) {
                $extra[$entity_type][$bundle]['form']['translation'] = [
                    'label' => t('Translation'),
                    'description' => t('Translation settings'),
                    'weight' => 10,
                ];
            }
        }
    }
    return $extra;
}

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