You are here

SensorConfigurable.php in Monitoring 7

File

lib/Drupal/monitoring/Sensor/SensorConfigurable.php
View source
<?php

/**
 * @file
 * Contains \Drupal\monitoring\Sensor\SensorConfigurable.
 */
namespace Drupal\monitoring\Sensor;


/**
 * Abstract configurable sensor class.
 *
 * Sensor extension providing generic functionality for custom
 * sensor settings.
 *
 * Custom sensor settings need to be implemented in an extending class.
 */
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.
  }

}

Classes

Namesort descending Description
SensorConfigurable Abstract configurable sensor class.