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()
- 10 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_type_alter()
- 11.x 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);
// We can't use getRevisionMetadataKeys() because it causes recursion.
$revision_metadata_keys = $entity_type->get('revision_metadata_keys');
$revision_metadata_keys = array_merge($revision_metadata_keys, [
'revision_log_message' => 'revision_log',
]);
$entity_type->set('revision_metadata_keys', $revision_metadata_keys);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.