-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongodb.install
More file actions
executable file
·54 lines (51 loc) · 1.42 KB
/
mongodb.install
File metadata and controls
executable file
·54 lines (51 loc) · 1.42 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
<?php
/**
* @file
* Installation for the module
*/
/**
* Implementation hook_requirements().
*/
function mongodb_requirements($phase) {
module_load_include('module', 'mongodb');
$requirements = array();
// Ensure translations don't break at install time
$t = get_t();
if (!extension_loaded('mongo')) {
$requirements['mongodb'] = array(
'title' => $t('Mongo database'),
'value' => $t('Not found'),
'description' => $t('Mongodb requires the PHP MongoDB extension to be installed.'),
'severity' => REQUIREMENT_ERROR
);
}
else {
try {
$mongo = mongodb_instance();
$res = array();
if ($mongo) {
$res = $mongo->execute("function() { return db.version(); }");
}
$requirements['mongodb'] = array(
'title' => $t('Mongo database'),
'value' => isset($res['retval']) ? $res['retval'] : t('unknown'),
'severity' => REQUIREMENT_OK
);
}
catch (Exception $e) {
$requirements['mongodb'] = array(
'title' => $t('Mongo database'),
'value' => $e->getMessage(),
'severity' => REQUIREMENT_ERROR
);
}
}
return $requirements;
}
/**
* Implementation of hook_update().
*/
function mongodb_update_6000() {
$return[] = update_sql("UPDATE system SET weight = -1 WHERE type = 'module' AND name = 'mongodb'");
return $return;
}