You are here

public function MonitoringCommands::disable in Monitoring 8

Disable specified monitoring sensor.

@usage drush monitoring-disable monitoring_git_dirty_tree Disables monitoring_git_dirty_tree sensor. @validate-module-enabled monitoring

@command monitoring:disable @aliases monitoring-disable

Parameters

string $sensor_name: Sensor name to disable.

File

src/Commands/MonitoringCommands.php, line 334

Class

MonitoringCommands
A Drush commandfile for the Monitoring module.

Namespace

Drupal\monitoring\Commands

Code

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

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