You are here

private function GitDirtyTreeSensorPlugin::runCommand in Monitoring 8

Run a command providing an error message.

Parameters

string $cmd: Command we want to run.

string $error: Error message to show when failing.

Return value

array Output of executing the Shell command.

1 call to GitDirtyTreeSensorPlugin::runCommand()
GitDirtyTreeSensorPlugin::buildConfigurationForm in src/Plugin/monitoring/SensorPlugin/GitDirtyTreeSensorPlugin.php
Form constructor.

File

src/Plugin/monitoring/SensorPlugin/GitDirtyTreeSensorPlugin.php, line 348
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\GitDirtyTreeSensorPlugin.

Class

GitDirtyTreeSensorPlugin
Monitors the git repository for dirty files.

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

Code

private function runCommand($cmd, $error) {
  $exit_code = 0;
  exec($this
    ->buildCommand($cmd), $output, $exit_code);
  if ($exit_code > 0) {
    $this
      ->messenger()
      ->addError($error);
  }
  return $output;
}