-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec_mapeditor.install.inc
110 lines (107 loc) · 3.02 KB
/
ec_mapeditor.install.inc
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* @file
* Define helper functions for install file.
*/
/**
* Defines and creates map layer field.
*
* Creates a map layer field which is a entity reference field, using inline
* entity form as widget. It is a multivalue field and it displays 'map_layer'
* as default view mode.
*/
function _ec_mapeditor_create_map_layer_field() {
// Clear field definition cache so that the entityreference field type is
// known to drupal during the enable hook. See
// https://www.drupal.org/node/1783886 and https://www.drupal.org/node/906668
_field_info_collate_types(TRUE);
if (field_info_field('map_layers')) {
watchdog('ec_mapeditor_layer', 'Field Map Countries not created because it exists already', array(), WATCHDOG_NOTICE, NULL);
}
else {
$field_bases = array();
$field_bases['map_layers'] = array(
'active' => 1,
'cardinality' => -1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'map_layers',
'indexes' => array(
'target_id' => array(
0 => 'target_id',
),
),
'locked' => 1,
'module' => 'entityreference',
'settings' => array(
'handler' => 'base',
'handler_settings' => array(
'behaviors' => array(
'views-select-list' => array(
'status' => 0,
),
),
'sort' => array(
'type' => 'none',
),
'target_bundles' => array(),
),
'target_type' => 'map_layer',
),
'translatable' => 0,
'type' => 'entityreference',
);
}
foreach ($field_bases as $field) {
field_create_field($field);
}
// Defines the map country field for the country layer bundle. Creates
// multiple line textarea field for CSV data.
$field_instances = array();
$field_instances['ec_mapeditor-mapeditor-map_layers'] = array(
'bundle' => 'map',
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'entityreference',
'settings' => array(
'links' => 1,
'use_content_language' => 1,
'view_mode' => 'map_layer',
),
'type' => 'entityreference_entity_view',
'weight' => 0,
),
),
'entity_type' => 'map',
'field_name' => 'map_layers',
'label' => 'Layers',
'required' => 0,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'inline_entity_form',
'settings' => array(
'fields' => array(),
'type_settings' => array(
'allow_existing' => 0,
'allow_new' => 1,
'delete_references' => 0,
'label_plural' => 'entities',
'label_singular' => 'entity',
'match_operator' => 'CONTAINS',
'override_labels' => 0,
),
),
'type' => 'inline_entity_form',
'weight' => 1,
),
);
foreach ($field_instances as $instance) {
field_create_instance($instance);
}
}