function field_test_entity_info_translatable

Same name in other branches
  1. 7.x modules/field/tests/field_test.entity.inc \field_test_entity_info_translatable()
  2. 9 core/modules/field/tests/modules/field_test/field_test.entity.inc \field_test_entity_info_translatable()
  3. 8.9.x core/modules/field/tests/modules/field_test/field_test.entity.inc \field_test_entity_info_translatable()
  4. 10 core/modules/field/tests/modules/field_test/field_test.entity.inc \field_test_entity_info_translatable()

Helper function to enable entity translations.

3 calls to field_test_entity_info_translatable()
field_test_entity_type_alter in core/modules/field/tests/modules/field_test/field_test.entity.inc
Implements hook_entity_type_alter().
TranslationTest::testTranslatableFieldSaveLoad in core/modules/field/tests/src/Kernel/TranslationTest.php
Tests translatable fields storage/retrieval.
TranslationWebTest::testFieldFormTranslationRevisions in core/modules/field/tests/src/Functional/TranslationWebTest.php
Tests field translations when creating a new revision.

File

core/modules/field/tests/modules/field_test/field_test.entity.inc, line 23

Code

function field_test_entity_info_translatable($entity_type_id = NULL, $translatable = NULL) {
    static $stored_value = [];
    if (isset($entity_type_id)) {
        $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
        $entity_type = $entity_definition_update_manager->getEntityType($entity_type_id);
        $stored_value[$entity_type_id] = $translatable;
        if ($translatable != $entity_type->isTranslatable()) {
            $entity_definition_update_manager->uninstallEntityType($entity_type);
            $entity_type->set('translatable', $translatable);
            $entity_definition_update_manager->installEntityType($entity_type);
        }
    }
    return $stored_value;
}

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