You are here

function multiversion_update_8104 in Multiversion 8

Use two different settings, one for supported and one for enabled entity types.

File

./multiversion.install, line 476

Code

function multiversion_update_8104() {
  $multiversion_settings = \Drupal::configFactory()
    ->getEditable('multiversion.settings');
  $supported = [
    'node',
    'taxonomy_term',
    'comment',
    'menu_link_content',
    'block_content',
    'file',
    'media',
    'shortcut',
    'entity_test',
    'entity_test_rev',
    'entity_test_mul',
    'entity_test_mulrev',
    'entity_test_local',
    'content_moderation_state',
    'replication_log',
    'paragraph',
    'poll',
    'poll_choice',
  ];
  $multiversion_settings
    ->set('supported_entity_types', $supported)
    ->save();
  $entity_types = \Drupal::entityTypeManager()
    ->getDefinitions();
  $enabled_entity_types = [];
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if (is_subclass_of($entity_type
      ->getStorageClass(), ContentEntityStorageInterface::class)) {
      $enabled_entity_types[] = $entity_type_id;
    }
  }
  $multiversion_settings
    ->set('enabled_entity_types', $enabled_entity_types)
    ->save();
}