You are here

public function PurgersService::getPluginsEnabled in Purge 8.3

Return value

string[] Associative array with enabled purgers: id => plugin_id.

Overrides ServiceBase::getPluginsEnabled

8 calls to PurgersService::getPluginsEnabled()
PurgersService::getLabels in src/Plugin/Purge/Purger/PurgersService.php
Retrieve all user-readable labels for all enabled purger instances.
PurgersService::getPluginsAvailable in src/Plugin/Purge/Purger/PurgersService.php
This method takes into account that purger plugins that are not multi-instantiable, can only be loaded once and are no longer available if they are already available. Plugins that are multi-instantiable, will always be listed.
PurgersService::getTypesByPurger in src/Plugin/Purge/Purger/PurgersService.php
Retrieve the list of supported invalidation types per purger instance.
PurgersService::initializePurgers in src/Plugin/Purge/Purger/PurgersService.php
Propagate $this->purgers by initializing the purgers.
PurgersService::invalidate in src/Plugin/Purge/Purger/PurgersService.php
Invalidate content from external caches.

... See full list

File

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

Class

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

Namespace

Drupal\purge\Plugin\Purge\Purger

Code

public function getPluginsEnabled() {
  if (is_null($this->pluginsEnabled)) {
    $this->pluginsEnabled = [];
    $plugins = $this->configFactory
      ->get('purge.plugins')
      ->get('purgers');
    $plugin_ids = array_keys($this
      ->getPlugins());

    // Put the plugin instances into $setting and use the order as key.
    if (!is_null($plugins)) {
      $setting = [];
      foreach ($plugins as $inst) {
        if (!in_array($inst['plugin_id'], $plugin_ids)) {

          // When a third-party provided purger was configured and its module
          // got uninstalled, the configuration renders invalid. Instead of
          // rewriting config or breaking hard, we ignore this silently.
          continue;
        }
        else {
          $setting[$inst['order_index']] = $inst;
        }
      }

      // Recreate the plugin ordering and propagate the enabled plugins array.
      ksort($setting);
      foreach ($setting as $inst) {
        $this->pluginsEnabled[$inst['instance_id']] = $inst['plugin_id'];
      }
    }
  }
  return $this->pluginsEnabled;
}