You are here

function header_and_footer_scripts_update_8201 in Header and Footer Scripts 8.2

Implements hook_update_N().

Adding new configuration variables and updating current configuration in it to avoid conflict with any other module.

File

./header_and_footer_scripts.install, line 29
Uninstall functions for header_and_footer_scripts module.

Code

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();
}