public function QueuerCommands::queuerAdd in Purge 8.3
Add a new queuer.
@usage drush p:queuer-add ID Add a queuer of type ID.
@command p:queuer-add @aliases puadd,p-queuer-add
Parameters
string $id: The plugin ID of the queuer to add.
array $options: Associative array of options whose values come from Drush.
File
- modules/
purge_drush/ src/ Commands/ QueuerCommands.php, line 46
Class
- QueuerCommands
- Configure Purge queuers from the command line.
Namespace
Drupal\purge_drush\CommandsCode
public function queuerAdd($id, array $options = [
'format' => 'string',
]) {
$enabled = $this->purgeQueuers
->getPluginsEnabled();
// Verify that the plugin exists.
if (!isset($this->purgeQueuers
->getPlugins()[$id])) {
throw new \Exception(dt('The given plugin does not exist!'));
}
// Verify that the plugin is available and thus not yet enabled.
if (!in_array($id, $this->purgeQueuers
->getPluginsAvailable())) {
if ($options['format'] == 'string') {
$this
->io()
->success(dt('The queuer is already enabled!'));
}
return;
}
// Define the new instance and store it.
$enabled[] = $id;
$this->purgeQueuers
->setPluginsEnabled($enabled);
if ($options['format'] == 'string') {
$this
->io()
->success(dt('The queuer has been added!'));
}
}