You are here

function mongodb_entity_type_alter in MongoDB 8

Implements hook_entity_type_alter

File

./mongodb.module, line 10
MongoDB core module.

Code

function mongodb_entity_type_alter(array &$entity_types) {

  /** @var \Drupal\Core\Config\Entity\ConfigEntityType[] $entity_types */
  foreach ($entity_types as $entity_type) {
    if ($entity_type
      ->getStorageClass() == 'Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage') {
      $entity_type
        ->setStorageClass('Drupal\\mongodb\\Entity\\ContentEntityStorage');
    }
    if (Drupal::moduleHandler()
      ->moduleExists('views') && is_subclass_of($entity_type
      ->getHandlerClass('views_data'), 'Drupal\\views\\EntityViewsData')) {
      $entity_type
        ->setHandlerClass('views_data', NULL);
    }
  }
}