StateValueSensorPlugin.php in Monitoring 8
File
src/Plugin/monitoring/SensorPlugin/StateValueSensorPlugin.php
View source
<?php
namespace Drupal\monitoring\Plugin\monitoring\SensorPlugin;
use Drupal\monitoring\SensorPlugin\ValueComparisonSensorPluginBase;
class StateValueSensorPlugin extends ValueComparisonSensorPluginBase {
protected function getValueDescription() {
return t('The expected value of state %key, current value: %actVal', array(
'%key' => $this->sensorConfig
->getSetting('key'),
'%actVal' => $this
->getValueText(),
));
}
protected function getValue() {
$state = $this
->getState();
$key = $this->sensorConfig
->getSetting('key');
if (empty($key)) {
return NULL;
}
return $state
->get($key);
}
protected function getState() {
return $this
->getService('state');
}
}