Skip to content

Commit

Permalink
[apigee#72] Remove imported entities on uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn committed Jul 11, 2019
1 parent 7a9850f commit acacffd
Showing 1 changed file with 16 additions and 0 deletions.
Expand Up @@ -34,3 +34,19 @@ function apigee_kickstart_content_install() {
}
}
}

/**
* Implements hook_uninstall().
*/
function apigee_kickstart_content_uninstall() {
$entity_type_manager = Drupal::entityTypeManager();

/** @var \Drupal\Core\Extension\Extension $module */
$module = Drupal::service('extension.list.module')->get('apigee_kickstart_content');
// Delete imported entities.
foreach ($module->info['default_content'] as $entity_type_id => $entity_ids) {
if (!empty($entity_ids) && ($entities = $entity_type_manager->getStorage($entity_type_id)->loadByProperties(['uuid' => $entity_ids]))) {
$entity_type_manager->getStorage($entity_type_id)->delete($entities);
}
}
}

0 comments on commit acacffd

Please sign in to comment.