You are here

public function QueuersService::getPluginsEnabled in Purge 8.3

Retrieve the configured plugin_ids that the service will use.

Return value

string[] Array with the plugin_ids of the enabled plugins.

Overrides ServiceBase::getPluginsEnabled

File

src/Plugin/Purge/Queuer/QueuersService.php, line 64

Class

QueuersService
Provides a service that provides access to loaded queuers.

Namespace

Drupal\purge\Plugin\Purge\Queuer

Code

public function getPluginsEnabled() {
  if (is_null($this->pluginsEnabled)) {

    // Build a mapping of all plugins and whether they are enabled by default.
    $this->pluginsEnabled = [];
    foreach ($this
      ->getPlugins() as $plugin_id => $definition) {
      $enable_by_default = $definition['enable_by_default'] === TRUE;
      $this->pluginsEnabled[$plugin_id] = $enable_by_default;
    }

    // Override the mapping with information stored in CMI, then filter out
    // everything that isn't enabled and finally flip the array with just ids.
    $queuers = $this->configFactory
      ->get('purge.plugins')
      ->get('queuers');
    if (!is_null($queuers)) {
      foreach ($queuers as $inst) {
        if (isset($this->pluginsEnabled[$inst['plugin_id']])) {
          $this->pluginsEnabled[$inst['plugin_id']] = $inst['status'];
        }
      }
    }
    foreach ($this->pluginsEnabled as $plugin_id => $status) {
      if (!$status) {
        unset($this->pluginsEnabled[$plugin_id]);
      }
    }
    $this->pluginsEnabled = array_keys($this->pluginsEnabled);
  }
  return $this->pluginsEnabled;
}