hal.install 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * @file
  4. * Update functions for the HAL module.
  5. */
  6. /**
  7. * Move 'link_domain' from 'rest.settings' to 'hal.settings'.
  8. */
  9. function hal_update_8301() {
  10. $config_factory = \Drupal::configFactory();
  11. // The default value for the 'link_domain' key is `~`, which is the YAML
  12. // equivalent of PHP's `NULL`. If the REST module is not installed, this is
  13. // the value we will store in 'hal.settings'.
  14. $link_domain = NULL;
  15. // But if the REST module was installed, we migrate its 'link_domain' setting,
  16. // because we are actually moving that setting from 'rest.settings' to
  17. // 'hal.settings'.
  18. $rest_settings = $config_factory->getEditable('rest.settings');
  19. if ($rest_settings->getRawData() !== []) {
  20. $link_domain = $rest_settings->get('link_domain');
  21. // Remove the 'link_domain' setting from 'rest.settings'.
  22. $rest_settings->clear('link_domain')
  23. ->save();
  24. }
  25. $hal_settings = $config_factory->getEditable('hal.settings');
  26. $hal_settings->set('link_domain', $link_domain);
  27. $hal_settings->save(TRUE);
  28. }