diff --git a/core/modules/views/views.install b/core/modules/views/views.install index d3c0dee..fe3110f 100644 --- a/core/modules/views/views.install +++ b/core/modules/views/views.install @@ -27,3 +27,29 @@ function views_schema_0() { $schema['cache_views_results'] = $cache_schema; return $schema; } + +/** + * Implements hook_modules_uninstalled(). + */ +function views_modules_uninstalled($modules) { + $entity_manager = Drupal::entityManager(); + $tables = array(); + foreach ($entity_manager->getDefinitions() as $entity_info) { + if (in_array($entity_info['provider'], $modules)) { + if (isset($entity_info['base_table'])) { + $tables[] = $entity_info['base_table']; + } + if (isset($entity_info['revision_table'])) { + $tables[] = $entity_info['revision_table']; + } + } + } + if ($tables) { + $query = Drupal::entityQuery('view') + ->condition('base_table', $tables) + ->execute(); + $view_storage = $entity_manager->getStorageController('view'); + $views = $view_storage->loadMultiple($query); + $view_storage->delete($views); + } +}