function DevelGenerateCommands::validate

Same name in other branches
  1. 4.x devel_generate/src/Commands/DevelGenerateCommands.php \Drupal\devel_generate\Commands\DevelGenerateCommands::validate()
  2. 5.x devel_generate/src/Commands/DevelGenerateCommands.php \Drupal\devel_generate\Commands\DevelGenerateCommands::validate()
  3. 5.x devel_generate/src/Drush/Commands/DevelGenerateCommands.php \Drupal\devel_generate\Drush\Commands\DevelGenerateCommands::validate()

@hook validate

Parameters

\Consolidation\AnnotatedCommand\CommandData $commandData:

Return value

\Consolidation\AnnotatedCommand\CommandError|null

File

devel_generate/src/Commands/DevelGenerateCommands.php, line 176

Class

DevelGenerateCommands
For commands that are parts of modules, Drush expects to find commandfiles in __MODULE__/src/Commands, and the namespace is Drupal/__MODULE__/Commands.

Namespace

Drupal\devel_generate\Commands

Code

public function validate(CommandData $commandData) {
    $manager = $this->getManager();
    $args = $commandData->input()
        ->getArguments();
    $commandName = array_shift($args);
    
    /** @var DevelGenerateBaseInterface $instance */
    $instance = $manager->createInstance($commandData->annotationData()
        ->get('pluginId'), array());
    $this->setPluginInstance($instance);
    $parameters = $instance->validateDrushParams($args, $commandData->input()
        ->getOptions());
    $this->setParameters($parameters);
}