You are here

function multiversion_modules_installed in Multiversion 8

Same name and namespace in other branches
  1. 8.2 multiversion.module \multiversion_modules_installed()

Implements hook_modules_installed().

File

./multiversion.module, line 601

Code

function multiversion_modules_installed($modules) {

  // Enable entity types provided by installed modules and supported by
  // Multiversion.
  $entity_type_manager = \Drupal::entityTypeManager();
  $supported_entity_types = \Drupal::configFactory()
    ->getEditable('multiversion.settings')
    ->get('supported_entity_types');
  $supported_entity_types = $supported_entity_types ?: [];
  $entities_to_enable = [];
  foreach ($supported_entity_types as $entity_type_id) {
    $entity_type = $entity_type_manager
      ->getDefinition($entity_type_id, FALSE);
    if (!empty($entity_type) && in_array($entity_type
      ->getProvider(), $modules)) {
      $entities_to_enable[$entity_type_id] = $entity_type;
    }
  }
  if (!empty($entities_to_enable)) {
    \Drupal::service('multiversion.manager')
      ->enableEntityTypes($entities_to_enable);
  }
}