You are here

public function WarmerCommands::validateWarmerNames in Warmer 8

Same name and namespace in other branches
  1. 2.x src/Commands/WarmerCommands.php \Drupal\warmer\Commands\WarmerCommands::validateWarmerNames()

Validate that queue permission exists.

Annotation value should be the name of the argument/option containing the name.

@hook validate @validate-warmer

Parameters

\Consolidation\AnnotatedCommand\CommandData $commandData:

Return value

\Consolidation\AnnotatedCommand\CommandError|NULL

File

src/Commands/WarmerCommands.php, line 159

Class

WarmerCommands
Drush commands for the Warmer module.

Namespace

Drupal\warmer\Commands

Code

public function validateWarmerNames(CommandData $commandData) {
  $arg_name = $commandData
    ->annotationData()
    ->get('validate-warmer', null);
  $warmer_ids = $commandData
    ->input()
    ->getArgument($arg_name);
  $warmer_ids = StringUtils::csvToArray($warmer_ids);
  $definitions = $this->warmerManager
    ->getDefinitions();
  $actual_warmer_ids = array_keys($definitions);
  $missing = array_diff($warmer_ids, $actual_warmer_ids);
  if (!empty($missing)) {
    $message = dt('Warmer plugin(s) not found: !names.', [
      '!names' => implode(', ', $missing),
    ]);
    return new CommandError($message);
  }
  return NULL;
}