-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathauto_entitylabel.install
More file actions
71 lines (65 loc) · 2.22 KB
/
auto_entitylabel.install
File metadata and controls
71 lines (65 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* @file
* Install, update, and uninstall functions for the Automatic Entity Label module.
*/
/**
* Implements hook_install().
*/
function auto_entitylabel_install() {
// Make sure hooks are invoked after core field hooks.
db_update('system')
->fields(array(
'weight' => 5
))
->condition('name', 'auto_entitylabel')
->execute();
// Migrate settings (permission+variable) from the auto_nodetitle module.
//_auto_entitylabel_ant_migrate();
// Set default config values for existing entities.
$config = config('auto_entitylabel.settings');
$bundles = _auto_entitylabel_get_bundles();
foreach ($bundles['keys'] as $key) {
$config->set($key, array(
'status' => AUTO_ENTITYLABEL_DISABLED,
'pattern' => '',
'php' => 0,
));
}
$config->save();
backdrop_set_message(t('Thank you for installing the <a href="@url_automatic_entity_label" target="blank">Automatic Entity Label</a>.', array(
'@url_automatic_entity_label' => 'https://backdropcms.org/project/auto_entitylabel',
)));
}
/**
* Convert variables to config.
*/
function auto_entitylabel_update_1000(&$sandbox) {
$config = config('auto_entitylabel.settings');
$bundles = _auto_entitylabel_get_bundles();
foreach ($bundles['keys'] as $key) {
$config_array = array();
$config_array['status'] = update_variable_get('auto_entitylabel_' . $key, 0);
update_variable_del('auto_entitylabel_' . $key);
$config_array['pattern'] = update_variable_get('auto_entitylabel_pattern_' . $key, '');
update_variable_del('auto_entitylabel_pattern_' . $key);
$config_array['php'] = update_variable_get('auto_entitylabel_php_' . $key, 0);
update_variable_del('auto_entitylabel_php_' . $key);
$config->set($key, $config_array);
}
$config->save();
}
/**
* Convert HTML strip setting.
*/
function auto_entitylabel_update_1001(&$sandbox) {
$config = config('auto_entitylabel.settings');
$bundles = _auto_entitylabel_get_bundles();
foreach ($bundles['keys'] as $key) {
$config_array = array();
$config_array['strip'] = update_variable_get('auto_entitylabel_strip_' . $key, 0);
update_variable_del('auto_entitylabel_strip_' . $key);
$config->set($key, $config_array);
}
$config->save();
}