You are here

function nivo_slider_uninstall in Nivo Slider 8

Same name and namespace in other branches
  1. 7 nivo_slider.install \nivo_slider_uninstall()

Implements hook_uninstall().

File

./nivo_slider.install, line 11
Install, update and uninstall functions for the Nivo Slider module.

Code

function nivo_slider_uninstall() {
  $config = \Drupal::config('nivo_slider.settings');

  // Get the current slider settings.
  $slides = $config
    ->get('slides');

  // Delete all of the slide images.
  foreach ($slides as $slide) {

    // Check if the slide has a file ID.
    if (isset($slide['fid'])) {

      // Load the file that corresponds to the file ID.
      $file_object = file_load($slide['fid']);

      // Delete the file.
      file_delete($file_object);
    }
  }

  // Delete the folder the slider images were contained in.
  $banner_folder = 'public://banner/';
  file_unmanaged_delete_recursive($banner_folder);
}