You are here

function TestSensorPlugin::__construct in Monitoring 8

Instantiates a sensor object.

Parameters

\Drupal\monitoring\Entity\SensorConfig $sensor_config: Sensor config object.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

Overrides SensorPluginBase::__construct

File

modules/test/src/Plugin/monitoring/SensorPlugin/TestSensorPlugin.php, line 29
Contains \Drupal\monitoring_test\Plugin\monitoring\SensorPlugin\TestSensorPlugin.

Class

TestSensorPlugin
Test sensor to report status as provided by external arguments.

Namespace

Drupal\monitoring_test\Plugin\monitoring\SensorPlugin

Code

function __construct(SensorConfig $sensor_config, $sensor_id, $definition) {
  parent::__construct($sensor_config, $sensor_id, $definition);

  // Load test sensor data which will be used in the runSensor() logic.
  $this->testSensorResultData = \Drupal::state()
    ->get('monitoring_test.sensor_result_data', array(
    'sensor_status' => NULL,
    'sensor_message' => NULL,
    'sensor_value' => NULL,
    'sensor_expected_value' => NULL,
    'sensor_exception_message' => NULL,
  ));
}