You are here

public function QueueService::setPluginsEnabled in Purge 8.3

Set the plugins used by the service and reload it.

Parameters

string[] $plugin_ids: Unassociative array with plugin IDs to be enabled.

Overrides ModifiableServiceInterface::setPluginsEnabled

See also

\Drupal\purge\ModifiableServiceInterface::getPluginsAvailable()

File

src/Plugin/Purge/Queue/QueueService.php, line 527

Class

QueueService
Provides the service that lets invalidations interact with a queue backend.

Namespace

Drupal\purge\Plugin\Purge\Queue

Code

public function setPluginsEnabled(array $plugin_ids) {
  if (count($plugin_ids) !== 1) {
    throw new \LogicException('Incorrect number of arguments.');
  }
  $plugin_id = current($plugin_ids);
  if (!isset($this->pluginManager
    ->getDefinitions()[$plugin_id])) {
    throw new \LogicException('Invalid plugin_id.');
  }
  $this->configFactory
    ->getEditable('purge.plugins')
    ->set('queue', $plugin_id)
    ->save();
  $this->logger
    ->debug("switched backend to @id.", [
    '@id' => $plugin_id,
  ]);
  $this
    ->reload();
  $this
    ->emptyQueue();
}