You are here

public function AdvisoriesConfigSubscriber::onConfigSave in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/system/src/EventSubscriber/AdvisoriesConfigSubscriber.php \Drupal\system\EventSubscriber\AdvisoriesConfigSubscriber::onConfigSave()

Deletes the stored response from the security advisories feed, if needed.

The stored response will only be deleted if the 'interval_hours' config setting is reduced from the previous value.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The configuration event.

File

core/modules/system/src/EventSubscriber/AdvisoriesConfigSubscriber.php, line 41

Class

AdvisoriesConfigSubscriber
Defines a config subscriber for changes to 'system.advisories'.

Namespace

Drupal\system\EventSubscriber

Code

public function onConfigSave(ConfigCrudEvent $event) : void {
  $saved_config = $event
    ->getConfig();
  if ($saved_config
    ->getName() === 'system.advisories' && $event
    ->isChanged('interval_hours')) {
    $original_interval = $saved_config
      ->getOriginal('interval_hours');
    if ($original_interval && $saved_config
      ->get('interval_hours') < $original_interval) {

      // If the new interval is less than the original interval, delete the
      // stored results.
      $this->securityAdvisoriesFetcher
        ->deleteStoredResponse();
    }
  }
}