function annotationcommand_adapter_call_validate_interface

master annotationcommand_adapter.inc annotationcommand_adapter_call_validate_interface($names, $hooks, CommandData $commandData)

Given a list of hooks that conform to the interface ValidatorInterface, call them and return the result.

Parameters

string[] $names All of the applicable names for the command being hooked:

string[] $hooks All of the HookManager hooks that should be called:

CommandData $commandData All of the parameter data associated with the: current command invokation, including the InputInterface, OutputInterface and AnnotationData

Return value

boolean|object

4 calls to annotationcommand_adapter_call_validate_interface()
annotationcommand_adapter_call_hook_command in includes/annotationcommand_adapter.inc
Convert from an old-style Drush 'command' hook into annotated-command hooks.
annotationcommand_adapter_call_hook_pre_command in includes/annotationcommand_adapter.inc
Convert from an old-style Drush pre-command hook into annotated-command hooks.
annotationcommand_adapter_call_hook_pre_validate in includes/annotationcommand_adapter.inc
Convert from an old-style Drush pre-validate hook into annotated-command hooks.
annotationcommand_adapter_call_hook_validate in includes/annotationcommand_adapter.inc
Convert from an old-style Drush validate hook into annotated-command hooks.

File

includes/annotationcommand_adapter.inc, line 731
annotationcommand_adapter.inc

Code

function annotationcommand_adapter_call_validate_interface($names, $hooks, CommandData $commandData) {
  $factory = \Drush::commandFactory();
  $hookManager = $factory->hookManager();
  $annotationData = $commandData->annotationData();

  $hooks = $hookManager->getHooks($names, $hooks, $annotationData);

  foreach ((array) $hooks as $hook) {
    // @todo: $hook might be a ValidatorInterface object. Support those?
    if (is_object($hook)) {
      continue;
    }
    $validated = $hook($commandData);
    // TODO: if $validated is a CommandError, maybe the best thing to do is 'return drush_set_error()'?
    if (is_object($validated) || ($validated === false)) {
      return $validated;
    }
  }
  return true;
}