comparison core/modules/hal/hal.install @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 }