xhprof_mongodb.install in XHProf 8
Same filename and directory in other branches
Install, update and uninstall functions for the XHProf module.
File
modules/xhprof_mongodb/xhprof_mongodb.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the XHProf module.
*/
function xhprof_mongodb_requirements($phase) {
$requirements = [];
// Ensure translations don't break at install time
if (extension_loaded('mongo')) {
module_load_include('module', 'mongodb');
$mongo = mongodb();
if (!$mongo instanceof MongoDB) {
$requirements['xhprof_mongodb'] = [
'title' => t('Mongodb'),
'value' => t('Not running'),
'description' => t('Unable to get a Mongodb collection object. This is required to create indexes on install.'),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}
/**
* Implementation of hook_install().
*/
function xhprof_mongodb_install() {
module_load_include('module', 'mongodb');
if ($collection = mongodb_collection('xhprof')) {
$collection
->ensureIndex([
"date" => -1,
"date" => 1,
]);
$collection
->ensureIndex([
"path" => -1,
"path" => 1,
]);
}
}
Functions
Name | Description |
---|---|
xhprof_mongodb_install | Implementation of hook_install(). |
xhprof_mongodb_requirements | @file Install, update and uninstall functions for the XHProf module. |