forked from nodespark/elasticsearch_connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elasticsearch_connector.install
135 lines (128 loc) · 3.62 KB
/
elasticsearch_connector.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
* @file
*
* The installtion file for elasticsearch_connector module.
*/
/**
* Implements hook_requirements().
*
* Check Elastica installation.
*/
function elasticsearch_connector_requirements($phase) {
$t = get_t();
if ($phase === 'install') {
if (version_compare(phpversion(), '5.3.9', '<')) {
return array(
'elasticsearch_connector' => array(
'title' => $t('The PHP version is not compatible with this module.'),
'description' => $t('The module requires PHP version bigger than or equal to version 5.3.9.'),
'severity' => REQUIREMENT_ERROR,
'value' => $t('PHP version not compatible.'),
),
);
}
}
if ($phase == 'runtime') {
if (!class_exists('\Elasticsearch\Client')) {
return array(
'elasticsearch_connector' => array(
'title' => $t('The Elasticsearch library is missing.'),
'description' => $t('The official library for Elasticsearch connection is missing.'),
'severity' => REQUIREMENT_ERROR,
'value' => $t('Elasticsearch library missing.'),
),
);
}
else {
return array(
'elasticsearch_connector' => array(
'title' => $t('Elasticsearch PHP library'),
'description' => $t('The official Elasticsearch library was correctly installed.'),
'severity' => REQUIREMENT_OK,
'value' => $t('OK'),
),
);
}
}
return array();
}
/**
* Implements hook_schema().
*/
function elasticsearch_connector_schema() {
$schema['elasticsearch_connector_cluster'] = array(
'description' => 'The base table for elasticsearch clusters.',
'export' => array(
'key' => 'cluster_id',
'admin_title' => 'name',
'api' => array(
'owner' => 'elasticsearch_connector',
'api' => 'elasticsearch_connector_defaults',
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'cluster_id' => array(
'description' => 'Unique identifier for the cluster environment',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => ''
),
'name' => array(
'description' => 'Human-readable name for the cluster',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''
),
'url' => array(
'description' => 'URL of master Node.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''
),
'status' => array(
'description' => 'Boolean indicating whether the entity is active or not.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'options' => array(
'description' => 'Other serialized options available for the cluster',
'type' => 'blob',
'not null' => TRUE,
'size' => 'normal',
),
),
'indexes' => array('status_idx' => array('status')),
'unique keys' => array(),
'foreign keys' => array(),
'primary key' => array('cluster_id'),
);
return $schema;
}
/**
* Implements hook_uninstall().
*
* Delete Search Api elasticsearch servers.
*/
function elasticsearch_connector_uninstall() {
variable_del('elasticsearch_connector_get_default_connector');
}
/**
* Implements hook_update_N().
*
* Update permissions.
*/
function elasticsearch_connector_update_7100(&$sandbox) {
db_update('role_permission')
->fields(array(
'permission' => 'administer elasticsearch connector',
))
->condition('permission', 'adminiser elasticsearch connector')
->execute();
}