You are here

abstract class SensorConfigurable in Monitoring 7

Abstract configurable sensor class.

Sensor extension providing generic functionality for custom sensor settings.

Custom sensor settings need to be implemented in an extending class.

Hierarchy

Expanded class hierarchy of SensorConfigurable

4 files declare their use of SensorConfigurable
SensorDisappearedSensors.php in lib/Drupal/monitoring/Sensor/Sensors/SensorDisappearedSensors.php
Contains \Drupal\monitoring\Sensor\Sensors\SensorDisappearedSensors.
SensorEnabledModules.php in lib/Drupal/monitoring/Sensor/Sensors/SensorEnabledModules.php
Contains \Drupal\monitoring\Sensor\Sensors\SensorEnabledModules.
SensorGitDirtyTree.php in lib/Drupal/monitoring/Sensor/Sensors/SensorGitDirtyTree.php
Contains \Drupal\monitoring\Sensor\Sensors\SensorGitDirtyTree.
SensorVariable.php in lib/Drupal/monitoring/Sensor/Sensors/SensorVariable.php
Drupal\monitoring\Sensor\Sensors\SensorVariable.

File

lib/Drupal/monitoring/Sensor/SensorConfigurable.php, line 17
Contains \Drupal\monitoring\Sensor\SensorConfigurable.

Namespace

Drupal\monitoring\Sensor
View source
abstract class SensorConfigurable extends Sensor implements SensorConfigurableInterface {

  /**
   * {@inheritdoc}
   */
  public function settingsForm($form, &$form_state) {

    // If sensor provides settings form, automatically provide settings to
    // enable the sensor.
    $form['enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enabled'),
      '#description' => t('Check to have the sensor trigger.'),
      '#default_value' => $this
        ->isEnabled(),
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function settingsFormValidate($form, &$form_state) {

    // Do nothing.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Sensor::$info protected property Current sensor info object.
Sensor::getSensorName public function Gets sensor name (not the label). Overrides SensorInterface::getSensorName
Sensor::isEnabled public function Determines if sensor is enabled. Overrides SensorInterface::isEnabled
Sensor::__construct function Instantiates a sensor object. 1
SensorConfigurable::settingsForm public function Gets settings form for a specific sensor. Overrides SensorConfigurableInterface::settingsForm 5
SensorConfigurable::settingsFormValidate public function Form validator for a sensor settings form. Overrides SensorConfigurableInterface::settingsFormValidate 1
SensorInterface::runSensor function Runs the sensor, updating $sensor_result. 13