You are here

function jquery_carousel_examples_uninstall in jQuery carousel 8

Implements hook_uninstall().

File

jquery_carousel_examples/jquery_carousel_examples.install, line 95
Adds dummy data for jquery carousel examples.

Code

function jquery_carousel_examples_uninstall() {

  // Collect all of the example nodes and delete them.
  $storage_handler = \Drupal::entityTypeManager()
    ->getStorage('node');
  $nodes = $storage_handler
    ->loadByProperties(array(
    'type' => 'jquery_carousel_example',
  ));

  // Ensure we have some nodes before deleting.
  if (!empty($nodes)) {
    $storage_handler
      ->delete($nodes);
    \Drupal::logger('jquery_carousel_examples')
      ->info(t('Deleted @count jquery_carousel_example nodes', array(
      '@count' => count($nodes),
    )), array());
  }

  // Now delete all of the configuration installed by this module.
  $dir = drupal_get_path('module', 'jquery_carousel_examples') . '/config/install';
  $files = FileSystemInterface::scanDirectory($dir, '/.*/');
  foreach ($files as $file) {
    \Drupal::configFactory()
      ->getEditable($file->name)
      ->delete();
  }
  \Drupal::logger('jquery_carousel_examples')
    ->info(t('Deleted jquery_carousel_example configuration'), array());
}