function field_test_entity_info_translatable in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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/ src/ Tests/ TranslationTest.php - Test translatable fields storage/retrieval.
- TranslationWebTest::testFieldFormTranslationRevisions in core/
modules/ field/ src/ Tests/ TranslationWebTest.php - Tests field translations when creating a new revision.
File
- core/
modules/ field/ tests/ modules/ field_test/ field_test.entity.inc, line 21 - Defines an entity type.
Code
function field_test_entity_info_translatable($entity_type_id = NULL, $translatable = NULL) {
$stored_value =& drupal_static(__FUNCTION__, array());
if (isset($entity_type_id)) {
$entity_manager = \Drupal::entityManager();
$original = $entity_manager
->getDefinition($entity_type_id);
$stored_value[$entity_type_id] = $translatable;
if ($translatable != $original
->isTranslatable()) {
$entity_manager
->clearCachedDefinitions();
$entity_type = $entity_manager
->getDefinition($entity_type_id);
$entity_manager
->onEntityTypeUpdate($entity_type, $original);
}
}
return $stored_value;
}