header_and_footer_scripts/header_and_footer_scripts.install
2021-11-01 13:18:42 +05:00

63 lines
1.9 KiB
Plaintext

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