You are here

header_and_footer_scripts.install in Header and Footer Scripts 8.2

Same filename and directory in other branches
  1. 8 header_and_footer_scripts.install

Uninstall functions for header_and_footer_scripts module.

File

header_and_footer_scripts.install
View source
<?php

/**
 * @file
 * Uninstall functions for header_and_footer_scripts module.
 */

/**
 * Implements hook_uninstall().
 */
function header_and_footer_scripts_uninstall() {
  \Drupal::service('config.factory')
    ->getEditable('header_and_footer_scripts.header.settings')
    ->delete();
  \Drupal::service('config.factory')
    ->getEditable('header_and_footer_scripts.body.settings')
    ->delete();
  \Drupal::service('config.factory')
    ->getEditable('header_and_footer_scripts.footer.settings')
    ->delete();
}

/**
 * Implements hook_update_N().
 *
 * Adding new configuration variables and updating current configuration
 * in it to avoid conflict with any other module.
 */
function header_and_footer_scripts_update_8201() {
  $body_section = \Drupal::config('hfs_body_scripts.settings')
    ->get();
  $footer_section = \Drupal::config('hfs_footer_scripts.settings')
    ->get();
  if (isset($body_section['styles'])) {
    \Drupal::configFactory()
      ->getEditable('header_and_footer_scripts.body.settings')
      ->set('styles', $body_section['styles'])
      ->save();
  }
  if (isset($body_section['scripts'])) {
    \Drupal::configFactory()
      ->getEditable('header_and_footer_scripts.body.settings')
      ->set('scripts', $body_section['scripts'])
      ->save();
  }
  \Drupal::service('config.factory')
    ->getEditable('hfs_body_scripts.settings')
    ->delete();
  if (isset($footer_section['styles'])) {
    \Drupal::configFactory()
      ->getEditable('header_and_footer_scripts.footer.settings')
      ->set('styles', $footer_section['styles'])
      ->save();
  }
  if (isset($footer_section['scripts'])) {
    \Drupal::configFactory()
      ->getEditable('header_and_footer_scripts.footer.settings')
      ->set('scripts', $footer_section['scripts'])
      ->save();
  }
  \Drupal::service('config.factory')
    ->getEditable('hfs_footer_scripts.settings')
    ->delete();
}