You are here

public function PurgersService::reload in Purge 8.3

Reload the service and reinstantiate all enabled plugins.

@warning Reloading a service implies that all cached data will be reset and that plugins get reinstantiated during the current request, which should normally not be used. This method is specifically used in tests.

Overrides ServiceBase::reload

1 call to PurgersService::reload()
PurgersService::setPluginsEnabled in src/Plugin/Purge/Purger/PurgersService.php
Set the plugins used by the service and reload it.

File

src/Plugin/Purge/Purger/PurgersService.php, line 367

Class

PurgersService
Provides the service that distributes access to one or more purgers.

Namespace

Drupal\purge\Plugin\Purge\Purger

Code

public function reload() {
  parent::reload();

  // Without this, the tests will throw "failed to instantiate user-supplied
  // statement class: CREATE TABLE {cache_config}".
  // phpcs:ignore DrupalPractice.Objects.GlobalDrupal.GlobalDrupal
  $this->configFactory = \Drupal::configFactory();

  // Drush commands appreciate it when the config cache gets cleared.
  if (php_sapi_name() === 'cli') {

    // phpcs:ignore DrupalPractice.Objects.GlobalDrupal.GlobalDrupal
    \Drupal::cache('config')
      ->deleteAll();
  }
  $this->purgers = NULL;
  $this->labels = NULL;
  $this->types = NULL;
  $this->typesByPurger = NULL;
}