abstract class SensorPluginBase in Monitoring 8
Abstract SensorPluginInterface implementation with common behaviour and will be extended by sensor plugins.
@todo more
Hierarchy
- class \Drupal\monitoring\SensorPlugin\SensorPluginBase implements SensorPluginInterface uses MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SensorPluginBase
19 files declare their use of SensorPluginBase
- CoreRequirementsSensorPlugin.php in src/
Plugin/ monitoring/ SensorPlugin/ CoreRequirementsSensorPlugin.php - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\CoreRequirementsSensorPlugin.
- CronLastRunAgeSensorPlugin.php in src/
Plugin/ monitoring/ SensorPlugin/ CronLastRunAgeSensorPlugin.php - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\CronLastRunAgeSensorPlugin.
- DatabaseDiskUsagePlugin.php in src/
Plugin/ monitoring/ SensorPlugin/ DatabaseDiskUsagePlugin.php - DisappearedSensorsSensorPlugin.php in src/
Plugin/ monitoring/ SensorPlugin/ DisappearedSensorsSensorPlugin.php - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\DisappearedSensorsSensorPlugin.
- DiskUsageSensorPlugin.php in src/
Plugin/ monitoring/ SensorPlugin/ DiskUsageSensorPlugin.php
File
- src/
SensorPlugin/ SensorPluginBase.php, line 21 - Contains \Drupal\monitoring\SensorPlugin\SensorPluginBase.
Namespace
Drupal\monitoring\SensorPluginView source
abstract class SensorPluginBase implements SensorPluginInterface {
use StringTranslationTrait;
use MessengerTrait;
/**
* Current sensor config object.
*
* @var \Drupal\monitoring\Entity\SensorConfig
*/
protected $sensorConfig;
protected $services = array();
/**
* The plugin_id.
*
* @var string
*/
protected $pluginId;
/**
* The plugin implementation definition.
*
* @var array
*/
protected $pluginDefinition;
/**
* Allows plugins to control if the value type can be configured.
*
* @var bool
*/
protected $configurableValueType = TRUE;
/**
* Instantiates a sensor object.
*
* @param \Drupal\monitoring\Entity\SensorConfig $sensor_config
* Sensor config object.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
function __construct(SensorConfig $sensor_config, $plugin_id, $plugin_definition) {
$this->pluginId = $plugin_id;
$this->pluginDefinition = $plugin_definition;
$this->sensorConfig = $sensor_config;
}
/**
* {@inheritdoc}
*/
public function addService($id, $service) {
$this->services[$id] = $service;
}
/**
* {@inheritdoc}
*/
public function getDefaultConfiguration() {
return array();
}
/**
* {@inheritdoc}
*/
public function getConfigurableValueType() {
return $this->configurableValueType;
}
/**
* {@inheritdoc}
*
* @todo: Replace with injection
*/
public function getService($id) {
return \Drupal::service($id);
}
/**
* {@inheritdoc}
*/
public function getSensorId() {
return $this->sensorConfig
->id();
}
/**
* {@inheritdoc}
*/
public function isEnabled() {
return (bool) $this->sensorConfig
->isEnabled();
}
/**
* {@inheritdoc}
*/
public function getPluginId() {
return $this->pluginId;
}
/**
* {@inheritdoc}
*/
public function getPluginDefinition() {
return $this->pluginDefinition;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return array();
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, SensorConfig $sensor_config, $plugin_id, $plugin_definition) {
return new static($sensor_config, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
// Do nothing.
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Do nothing.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
SensorPluginBase:: |
protected | property | Allows plugins to control if the value type can be configured. | 6 |
SensorPluginBase:: |
protected | property | The plugin implementation definition. | |
SensorPluginBase:: |
protected | property | The plugin_id. | |
SensorPluginBase:: |
protected | property | Current sensor config object. | |
SensorPluginBase:: |
protected | property | ||
SensorPluginBase:: |
public | function |
Service setter. Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
13 |
SensorPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides SensorPluginInterface:: |
4 |
SensorPluginBase:: |
public static | function |
Creates an instance of the sensor with config. Overrides SensorPluginInterface:: |
7 |
SensorPluginBase:: |
public | function |
Configurable value type. Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
Default configuration for a sensor. Overrides SensorPluginInterface:: |
8 |
SensorPluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
SensorPluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
SensorPluginBase:: |
public | function |
Gets sensor name (not the label). Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
@todo: Replace with injection Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
Determines if sensor is enabled. Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
3 |
SensorPluginBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
2 |
SensorPluginBase:: |
function | Instantiates a sensor object. | 8 | |
SensorPluginInterface:: |
public | function | Runs the sensor, updating $sensor_result. | 22 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |