function entity_schema_test_entity_type_alter
Same name in other branches
- 9 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_type_alter()
- 8.9.x core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_type_alter()
- 10 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_type_alter()
Implements hook_entity_type_alter().
File
-
core/
modules/ system/ tests/ modules/ entity_schema_test/ entity_schema_test.module, line 18
Code
function entity_schema_test_entity_type_alter(array &$entity_types) {
// Allow a test to tell us whether or not to alter the entity type.
if (\Drupal::state()->get('entity_schema_update')) {
$entity_type = $entity_types['entity_test_update'];
if ($entity_type instanceof ContentEntityTypeInterface) {
$entity_type->set('translatable', TRUE);
$entity_type->set('data_table', 'entity_test_update_data');
// Update the keys with a revision ID.
$keys = $entity_type->getKeys();
$keys['revision'] = 'revision_id';
$entity_type->set('entity_keys', $keys);
$entity_type->setRevisionMetadataKey('revision_log_message', 'revision_log');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.