You are here

public function ValueComparisonSensorPluginBase::buildConfigurationForm in Monitoring 8

Adds expected value setting field into the sensor settings form.

Overrides SensorPluginBase::buildConfigurationForm

1 call to ValueComparisonSensorPluginBase::buildConfigurationForm()
ConfigValueSensorPlugin::buildConfigurationForm in src/Plugin/monitoring/SensorPlugin/ConfigValueSensorPlugin.php
Adds UI for variables config object and key.
1 method overrides ValueComparisonSensorPluginBase::buildConfigurationForm()
ConfigValueSensorPlugin::buildConfigurationForm in src/Plugin/monitoring/SensorPlugin/ConfigValueSensorPlugin.php
Adds UI for variables config object and key.

File

src/SensorPlugin/ValueComparisonSensorPluginBase.php, line 68
Contains \Drupal\monitoring\SensorPlugin\ValueComparisonSensorPluginBase

Class

ValueComparisonSensorPluginBase
Provides abstract functionality for a value comparison sensor.

Namespace

Drupal\monitoring\SensorPlugin

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['value'] = array(
    '#title' => t('Expected value'),
    '#description' => $this
      ->getValueDescription(),
    '#default_value' => $this
      ->getExpectedValue(),
  );
  if ($this->sensorConfig
    ->isBool()) {
    $form['value']['#type'] = 'checkbox';
  }
  elseif ($this->sensorConfig
    ->isNumeric()) {
    $form['value']['#type'] = 'number';
  }
  else {
    $form['value']['#type'] = 'textfield';
  }
  return $form;
}