You are here

public function RequirementsIgnore::sensorUnignoreKey in Monitoring 8

Removes sensor key from the excluded list.

Parameters

\Drupal\monitoring\Entity\SensorConfig $monitoring_sensor_config:

Return value

\Symfony\Component\HttpFoundation\RedirectResponse

1 string reference to 'RequirementsIgnore::sensorUnignoreKey'
monitoring.routing.yml in ./monitoring.routing.yml
monitoring.routing.yml

File

src/Controller/RequirementsIgnore.php, line 81
Contains \Drupal\monitoring\Controller\RequirementsIgnore.

Class

RequirementsIgnore

Namespace

Drupal\monitoring\Controller

Code

public function sensorUnignoreKey(SensorConfig $monitoring_sensor_config, $key) {
  if (in_array($key, $monitoring_sensor_config->settings['exclude_keys'])) {
    if ($index = array_search($key, $monitoring_sensor_config->settings['exclude_keys'])) {
      unset($monitoring_sensor_config->settings['exclude_keys'][$index]);
    }
    $monitoring_sensor_config
      ->save();
    $this
      ->messenger()
      ->addMessage($this
      ->t('Removed the sensor %name (%key) from the excluded list.', array(
      '%name' => $monitoring_sensor_config
        ->getLabel(),
      '%key' => $key,
    )));
  }
  $url = $monitoring_sensor_config
    ->toUrl('details-form');
  return $this
    ->redirect($url
    ->getRouteName(), $url
    ->getRouteParameters());
}