You are here

public function SensorManager::getSensorConfigByName in Monitoring 8

Returns monitoring sensor config for a given sensor.

Directly use SensorConfig::load($name) if sensor existence assured.

Parameters

string $sensor_name: Sensor id.

Return value

\Drupal\monitoring\Entity\SensorConfig A single SensorConfig instance.

Throws

\Drupal\monitoring\Sensor\NonExistingSensorException Thrown if the requested sensor does not exist.

2 calls to SensorManager::getSensorConfigByName()
SensorManager::disableSensor in src/Sensor/SensorManager.php
Disable a sensor.
SensorManager::enableSensor in src/Sensor/SensorManager.php
Enable a sensor.

File

src/Sensor/SensorManager.php, line 142
Contains \Drupal\monitoring\Sensor\SensorManager.

Class

SensorManager
Manages sensor definitions and settings.

Namespace

Drupal\monitoring\Sensor

Code

public function getSensorConfigByName($sensor_name) {
  $sensor_config = SensorConfig::load($sensor_name);
  if ($sensor_config == NULL) {
    throw new NonExistingSensorException(new FormattableMarkup('Sensor @sensor_name does not exist', array(
      '@sensor_name' => $sensor_name,
    )));
  }
  return $sensor_config;
}