deleteStoredResponse example


  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();
      }
    }
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    $events[ConfigEvents::SAVE][] = ['onConfigSave'];
    return $events;
  }

}
/** * Sets the test endpoint for the advisories JSON feed. * * @param string $test_endpoint * The test endpoint. * @param bool $delete_stored_response * Whether to delete stored feed response. */
  public static function setTestEndpoint(string $test_endpoint, bool $delete_stored_response = FALSE): void {
    \Drupal::state()->set('advisories_test_endpoint', $test_endpoint);
    if ($delete_stored_response) {
      \Drupal::service('system.sa_fetcher')->deleteStoredResponse();
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.