You are here

public function ConfigValueSensorPlugin::buildConfigurationForm in Monitoring 8

Adds UI for variables config object and key.

Overrides ValueComparisonSensorPluginBase::buildConfigurationForm

File

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

Class

ConfigValueSensorPlugin
Generic sensor that checks for a configuration value.

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);

  // Add weight to display config key before expected value.
  $form['config'] = array(
    '#type' => 'textfield',
    '#default_value' => $this->sensorConfig
      ->getSetting('config') ? $this->sensorConfig
      ->getSetting('config') : '',
    '#autocomplete_route_name' => 'monitoring.config_autocomplete',
    '#maxlength' => 255,
    '#title' => t('Config Object'),
    '#required' => TRUE,
    '#weight' => -1,
  );
  $form['key'] = array(
    '#type' => 'textfield',
    '#default_value' => $this->sensorConfig
      ->getSetting('key') ? $this->sensorConfig
      ->getSetting('key') : '',
    '#maxlength' => 255,
    '#title' => t('Key'),
    '#required' => TRUE,
    '#weight' => -1,
  );
  return $form;
}