You are here

public function RequirementsIgnore::sensorIgnoreKey in Monitoring 8

Adds sensor key into the excluded list.

Parameters

\Drupal\monitoring\Entity\SensorConfig $monitoring_sensor_config:

Return value

\Symfony\Component\HttpFoundation\RedirectResponse

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

File

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

Class

RequirementsIgnore

Namespace

Drupal\monitoring\Controller

Code

public function sensorIgnoreKey(SensorConfig $monitoring_sensor_config, $key) {
  if (!in_array($key, $monitoring_sensor_config->settings['exclude_keys'])) {
    $monitoring_sensor_config->settings['exclude_keys'][] = $key;
    $monitoring_sensor_config
      ->save();
    $this
      ->messenger()
      ->addMessage($this
      ->t('Added the sensor %name (%key) into 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());
}