function monitoring_install in Monitoring 8
Implements hook_install().
Declares initial set of sensors.
2 calls to monitoring_install()
- MonitoringCoreKernelTest::setUp in tests/
src/ Kernel/ MonitoringCoreKernelTest.php - MonitoringMailKernelTest::setUp in modules/
monitoring_mail/ tests/ src/ Kernel/ MonitoringMailKernelTest.php
File
- ./
monitoring.install, line 19 - Monitoring base install file.
Code
function monitoring_install() {
if (\Drupal::service('config.installer')
->isSyncing()) {
// Don't create any config when syncing.
// @todo change to $is_syncing param after 8.9 is minimum per
// https://www.drupal.org/node/3098920
return;
}
// Declares initial set of search api sensors (if module exists).
if (\Drupal::moduleHandler()
->moduleExists('search_api')) {
foreach (Index::loadMultiple() as $index) {
$sensor = SensorConfig::create(array(
'id' => 'search_api_' . $index
->id(),
'label' => new FormattableMarkup('Search index queue size of @index', array(
'@index' => $index
->label(),
)),
'plugin_id' => 'search_api_unindexed',
'value_type' => 'number',
'value_label' => 'Unindexed items',
'category' => 'Search API',
// Cache for 15 minutes.
'caching_time' => 900,
'status' => TRUE,
'settings' => array(
'index_id' => $index
->id(),
),
'dependencies' => array(
'module' => 'search_api',
),
));
$sensor
->save();
}
}
// Declares core requirements sensors.
// Load .install files
include_once DRUPAL_ROOT . '/core/includes/install.inc';
drupal_load_updates();
foreach (\Drupal::moduleHandler()
->getImplementations('requirements') as $module) {
initialize_requirements_sensors($module);
}
}