You are here

protected function PurgersService::initializePurgers in Purge 8.3

Propagate $this->purgers by initializing the purgers.

5 calls to PurgersService::initializePurgers()
PurgersService::capacityTracker in src/Plugin/Purge/Purger/PurgersService.php
Get the capacity tracker.
PurgersService::getLabels in src/Plugin/Purge/Purger/PurgersService.php
Retrieve all user-readable labels for all enabled purger instances.
PurgersService::getTypes in src/Plugin/Purge/Purger/PurgersService.php
Retrieve the list of supported invalidation types.
PurgersService::getTypesByPurger in src/Plugin/Purge/Purger/PurgersService.php
Retrieve the list of supported invalidation types per purger instance.
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 387

Class

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

Namespace

Drupal\purge\Plugin\Purge\Purger

Code

protected function initializePurgers() {
  if (!is_null($this->purgers)) {
    return;
  }

  // Iterate each purger plugin we should load and instantiate them.
  $this->purgers = [];
  foreach ($this
    ->getPluginsEnabled() as $id => $plugin_id) {
    $this->purgers[$id] = $this->pluginManager
      ->createInstance($plugin_id, [
      'id' => $id,
    ]);
    $this->purgers[$id]
      ->setLogger($this->purgeLogger
      ->get(sprintf(self::LOGGER_PURGERS_FORMAT, $plugin_id, $id)));
    $this->logger
      ->debug("loading purger @id (@plugin_id).", [
      '@id' => $id,
      '@plugin_id' => $plugin_id,
    ]);
  }

  // Pass the purger instance onto depending objects.
  $this->capacityTracker
    ->setPurgers($this->purgers);
  $this->runtimeMeasurementTracker
    ->setPurgers($this->purgers);
}