You are here

nivo_slider.install in Nivo Slider 8

Same filename and directory in other branches
  1. 7 nivo_slider.install

Install, update and uninstall functions for the Nivo Slider module.

File

nivo_slider.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Nivo Slider module.
 */

/**
 * Implements hook_uninstall().
 */
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);
}

/**
 * Move nivo_slider settings from variables to config.
 *
 * @ingroup config_upgrade
 */
function nivo_slider_update_8000() {
  update_variables_to_config('nivo_slider.settings', [
    'nivo_slider_banner_settings' => 'slides',
    'nivo_slider_banner_html_captions' => 'html_captions',
    'nivo_slider_theme' => 'options.theme',
    'nivo_slider_image_style' => 'options.image_style',
    'nivo_slider_image_style_slide' => 'options.image_style_slide',
    'nivo_slider_image_style_thumb' => 'options.image_style_thumb',
    'nivo_slider_random_start' => 'options.random_start',
    'nivo_slider_start_slide' => 'options.start_slide',
    'nivo_slider_effect' => 'options.effect',
    'nivo_slider_slices' => 'options.slices',
    'nivo_slider_box_columns' => 'options.box_columns',
    'nivo_slider_box_rows' => 'options.box_rows',
    'nivo_slider_animation_speed' => 'options.animation_speed',
    'nivo_slider_pause_on_hover' => 'options.pause_on_hover',
    'nivo_slider_directional_navigation' => 'options.directional_navigation',
    'nivo_slider_next_text' => 'options.next_text',
    'nivo_slider_previous_text' => 'options.previous_text',
    'nivo_slider_control_navigation' => 'options.control_navigation',
    'nivo_slider_control_nav_thumbs' => 'options.control_nav_thumbs',
    'nivo_slider_manual_advance' => 'options.manual_advance',
    'nivo_slider_pause_time' => 'options.pause_time',
  ]);
}

Functions

Namesort descending Description
nivo_slider_uninstall Implements hook_uninstall().
nivo_slider_update_8000 Move nivo_slider settings from variables to config.