/
pants.install
75 lines (71 loc) · 2.17 KB
/
pants.install
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
72
73
74
75
<?php
function pants_schema() {
$schema['pants_history'] = array(
'description' => 'TODO: please describe this table!',
'fields' => array(
'uid' => array(
'description' => 'TODO: please describe this field!',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'status' => array(
'description' => 'TODO: please describe this field!',
'type' => 'int',
'not null' => TRUE,
),
'changed' => array(
'description' => 'TODO: please describe this field!',
'type' => 'int',
'not null' => TRUE,
),
'changed_by' => array(
'description' => 'TODO: please describe this field!',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
);
return $schema;
}
function pants_install() {
// Get the default User display's content
$content = entity_get_display('user', 'user', 'default')
->get('content');
// Add pants_status as a displayed field
$content['pants_status'] = array(
'type' => 'boolean',
'weight' => 0,
'settings' => array(),
'third_party_settings' => array(),
'label' => 'above'
);
// Get the default User display's depdendencies
$dependencies = entity_get_display('user', 'user', 'default')
->get('dependencies');
// Check to see if pants_status already added
if (!in_array('field.field.user.user.pants_status', $dependencies['entity'])) {
$dependencies['entity'][] = 'field.field.user.user.pants_status';
}
// Save the new display
entity_get_display('user', 'user', 'default')
->set('content', $content)
->set('dependencies', $dependencies)
->save();
// Get the default User form display's content
$content = entity_get_form_display('user', 'user', 'default')
->get('content');
// Add pants_status
$content['pants_status'] = array(
'type' => 'boolean_checkbox',
'weight' => 0,
'settings' => array ('display_label' => 1),
'third_party_settings' => array()
);
// Save the form display
entity_get_form_display('user', 'user', 'default')
->set('content', $content)
->save();
}
// @todo uninstall entity displays and fields