You are here

function api_test_uninstall in Lightning API 8

Same name and namespace in other branches
  1. 8.2 modules/api_test/api_test.install \api_test_uninstall()

Implements hook_uninstall().

File

modules/api_test/api_test.install, line 93

Code

function api_test_uninstall() {

  // Delete the user created during install.
  $username = 'api-test-user';
  $storage = \Drupal::entityTypeManager()
    ->getStorage('user');
  $users = $storage
    ->loadByProperties([
    'name' => $username,
  ]);
  $storage
    ->delete($users);

  // Delete the client created during install.
  $client_uuid = 'api_test-oauth2-client';
  $storage = \Drupal::entityTypeManager()
    ->getStorage('consumer');
  $clients = $storage
    ->loadByProperties([
    'uuid' => $client_uuid,
  ]);
  $storage
    ->delete($clients);

  // Delete the nodes created during install.
  $storage = \Drupal::entityTypeManager()
    ->getStorage('node');
  $nodes = $storage
    ->loadByProperties([
    'body' => '--TESTING--',
  ]);
  $storage
    ->delete($nodes);
}