function entity_test_entity_bundle_info_alter

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_bundle_info_alter()
  2. 8.9.x core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_bundle_info_alter()
  3. 10 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_bundle_info_alter()

Implements hook_entity_bundle_info_alter().

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 242

Code

function entity_test_entity_bundle_info_alter(&$bundles) {
    $entity_info = \Drupal::entityTypeManager()->getDefinitions();
    $state = \Drupal::state();
    foreach ($bundles as $entity_type_id => &$all_bundle_info) {
        if ($entity_info[$entity_type_id]->getProvider() == 'entity_test') {
            if ($state->get('entity_test.translation') && $entity_info[$entity_type_id]->isTranslatable()) {
                foreach ($all_bundle_info as $bundle_name => &$bundle_info) {
                    $bundle_info['translatable'] = TRUE;
                    if ($state->get('entity_test.untranslatable_fields.default_translation_affected')) {
                        $bundle_info['untranslatable_fields.default_translation_affected'] = TRUE;
                    }
                }
            }
        }
    }
}

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