You are here

public function PurgerCommands::purgerRemove in Purge 8.3

Remove a purger instance.

@usage drush p:purger-rm ID Remove the given purger.

@command p:purger-rm @aliases pprm,p-purger-rm

Parameters

string $id: The instance ID of the purger to remove.

array $options: Associative array of options whose values come from Drush.

File

modules/purge_drush/src/Commands/PurgerCommands.php, line 252

Class

PurgerCommands
Configure Purge Purgers from the command line.

Namespace

Drupal\purge_drush\Commands

Code

public function purgerRemove($id, array $options = [
  'format' => 'string',
]) {
  $enabled = $this->purgePurgers
    ->getPluginsEnabled();

  // Verify that the purger instance exists.
  if (!isset($enabled[$id])) {
    throw new \Exception(dt('The given instance ID is not valid!'));
  }

  // Remove the purger instance and finish command execution.
  unset($enabled[$id]);
  $this->purgePurgers
    ->setPluginsEnabled($enabled);
  if ($options['format'] == 'string') {
    $this
      ->io()
      ->success(dt('The purger has been removed!'));
  }
}