You are here

function initialize_requirements_sensors in Monitoring 8

Initialize core requirements sensors.

Parameters

string $module: Name of the module to create a requirements sensor for.

Return value

bool TRUE if a sensor was created, FALSE otherwise.

3 calls to initialize_requirements_sensors()
monitoring_install in ./monitoring.install
Implements hook_install().
monitoring_modules_installed in ./monitoring.module
Implements hook_modules_installed().
SensorManager::rebuildSensors in src/Sensor/SensorManager.php
Rebuild the sensor list.

File

./monitoring.module, line 83
Monitoring bootstrap file.

Code

function initialize_requirements_sensors($module) {

  // Skip update module as there is a separate sensors for core and contrib.
  if ($module == 'update') {
    return FALSE;
  }
  if (!empty(\Drupal::configFactory()
    ->get('monitoring.settings')
    ->get('disable_sensor_autocreate'))) {
    return FALSE;
  }
  $sensor = SensorConfig::create(array(
    'id' => 'core_requirements_' . $module,
    'label' => new FormattableMarkup('Module @module', array(
      '@module' => $module,
    )),
    'description' => new FormattableMarkup('Requirements of the @module module', array(
      '@module' => $module,
    )),
    'plugin_id' => 'core_requirements',
    'value_type' => 'no_value',
    'category' => 'Requirements',
    'caching_time' => 3600,
    'status' => TRUE,
    'settings' => array(
      'module' => $module,
      // List requirements keys which reports will be suppressed.
      'exclude_keys' => array(),
    ),
    'dependencies' => array(
      'module' => $module,
    ),
  ));

  // Ignore the cron key for system requirements, as we have a separate
  // sensor for this.
  if ($module == 'system') {
    $sensor->settings['exclude_keys'][] = 'cron';
  }
  $sensor
    ->save();
  return TRUE;
}