You are here

public function MonitoringCommands::enable in Monitoring 8

Enable specified monitoring sensor.

@usage drush monitoring-enable monitoring_git_dirty_tree Enables monitoring_git_dirty_tree sensor. @validate-module-enabled monitoring

@command monitoring:enable @aliases monitoring-enable

Parameters

string $sensor_name: Sensor name to enable.

File

src/Commands/MonitoringCommands.php, line 307

Class

MonitoringCommands
A Drush commandfile for the Monitoring module.

Namespace

Drupal\monitoring\Commands

Code

public function enable($sensor_name) {
  $sensor_config = $this->sensorManager
    ->getSensorConfigByName($sensor_name);
  if ($sensor_config
    ->isEnabled()) {
    $message = dt('The sensor @name is already enabled.', [
      '@name' => $sensor_config
        ->label(),
    ]);
    $this
      ->logger()
      ->notice($message);
    return;
  }
  $this->sensorManager
    ->enableSensor($sensor_name);
  $message = dt('The sensor @name was enabled.', [
    '@name' => $sensor_config
      ->label(),
  ]);

  /* @noinspection PhpUndefinedMethodInspection */
  $this
    ->logger()
    ->success($message);
}