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