class SensorVariable in Monitoring 7
Monitors a variable value.
Hierarchy
- class \Drupal\monitoring\Sensor\Sensor implements SensorInterface
- class \Drupal\monitoring\Sensor\SensorConfigurable implements SensorConfigurableInterface
- class \Drupal\monitoring\Sensor\Sensors\SensorVariable
- class \Drupal\monitoring\Sensor\SensorConfigurable implements SensorConfigurableInterface
Expanded class hierarchy of SensorVariable
See also
File
- lib/
Drupal/ monitoring/ Sensor/ Sensors/ SensorVariable.php, line 18 - Drupal\monitoring\Sensor\Sensors\SensorVariable.
Namespace
Drupal\monitoring\Sensor\SensorsView source
class SensorVariable extends SensorConfigurable {
/**
* {@inheritdoc}
*/
public function settingsForm($form, &$form_state) {
$form = parent::settingsForm($form, $form_state);
if (is_array($this->info
->getSetting('variable_value'))) {
return $form;
}
$form['variable_value'] = array(
'#type' => 'textfield',
'#title' => t('Expected value of variable %variable', array(
'%variable' => $this->info
->getSetting('variable_name'),
)),
'#default_value' => $this->info
->getSetting('variable_value'),
);
return $form;
}
/**
* {@inheritdoc}
*/
public function runSensor(SensorResultInterface $result) {
$result
->setValue(variable_get($this->info
->getSetting('variable_name'), $this->info
->getSetting('variable_default_value')));
$result
->setExpectedValue($this->info
->getSetting('variable_value'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Sensor:: |
protected | property | Current sensor info object. | |
Sensor:: |
public | function |
Gets sensor name (not the label). Overrides SensorInterface:: |
|
Sensor:: |
public | function |
Determines if sensor is enabled. Overrides SensorInterface:: |
|
Sensor:: |
function | Instantiates a sensor object. | 1 | |
SensorConfigurable:: |
public | function |
Form validator for a sensor settings form. Overrides SensorConfigurableInterface:: |
1 |
SensorVariable:: |
public | function |
Runs the sensor, updating $sensor_result. Overrides SensorInterface:: |
|
SensorVariable:: |
public | function |
Gets settings form for a specific sensor. Overrides SensorConfigurable:: |