You are here

function entity_schema_test_entity_type_alter in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_type_alter()
  2. 9 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
Test module for the entity API providing a bundle field.

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');
    }
  }
}