You are here

public function GitDirtyTreeSensorPlugin::resultVerbose in Monitoring 8

Provide additional info about sensor call.

This method is only executed on request. It is guaranteed that runSensor() is executed before this method.

Parameters

\Drupal\monitoring\Result\SensorResultInterface $result: Sensor result.

Return value

array Sensor call verbose info as render array.

Overrides ExtendedInfoSensorPluginInterface::resultVerbose

File

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

Class

GitDirtyTreeSensorPlugin
Monitors the git repository for dirty files.

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

Code

public function resultVerbose(SensorResultInterface $result) {
  $output = [];
  $branch_control = $this->sensorConfig
    ->getSetting('check_branch');
  if ($branch_control) {
    $output['check_branch'] = array(
      '#type' => 'fieldset',
      '#title' => t('Check branch'),
      '#attributes' => array(),
    );
    $output['check_branch']['cmd'] = array(
      '#type' => 'item',
      '#title' => t('Command'),
      '#markup' => $this
        ->buildCommand('actual_branch_cmd'),
    );
    $output['check_branch']['output'] = array(
      '#type' => 'item',
      '#title' => t('Output'),
      '#markup' => $this->actualBranch,
      '#description' => t('Shows the current branch.'),
      '#description_display' => 'after',
    );
  }
  $output['ahead'] = array(
    '#type' => 'fieldset',
    '#title' => t('Ahead'),
    '#attributes' => array(),
  );
  $output['ahead']['cmd'] = array(
    '#type' => 'item',
    '#title' => t('Command'),
    '#markup' => $this
      ->buildCommand('ahead_cmd'),
  );
  $output['ahead']['output'] = array(
    '#type' => 'item',
    '#title' => t('Output'),
    '#markup' => '<pre>' . implode("\n", $this->distance) . '</pre>',
    '#description' => t('Shows local commits that have not been pushed.'),
    '#description_display' => 'after',
  );
  $output['status'] = array(
    '#type' => 'fieldset',
    '#title' => t('Status'),
    '#attributes' => array(),
  );
  $output['status']['cmd'] = array(
    '#type' => 'item',
    '#title' => t('Command'),
    '#markup' => $this
      ->buildCommand('status_cmd'),
  );
  $output['status']['output'] = array(
    '#type' => 'item',
    '#title' => t('Output'),
    '#markup' => '<pre>' . implode("\n", $this->status) . '</pre>',
    '#description' => t('Shows uncommitted, changed and deleted files.'),
    '#description_display' => 'after',
  );
  $output['submodules'] = array(
    '#type' => 'fieldset',
    '#title' => t('Submodules'),
    '#attributes' => array(),
  );
  $output['submodules']['cmd'] = array(
    '#type' => 'item',
    '#title' => t('Command'),
    '#markup' => $this
      ->buildCommand('submodules_cmd'),
  );
  $output['submodules']['output'] = array(
    '#type' => 'item',
    '#title' => t('Output'),
    '#markup' => '<pre>' . implode("\n", $this->submodules) . '</pre>',
    '#description' => t('Run "git submodule init" to initialize missing submodules ("-" prefix) or "git submodule update" to update submodules to the correct commit ("+" prefix).'),
    '#description_display' => 'after',
  );
  return $output;
}