Skip to content

Commit

Permalink
Looks like I may have removed some injection points that are actually…
Browse files Browse the repository at this point in the history
… necessary.
  • Loading branch information
greg-1-anderson committed Aug 29, 2020
1 parent ddb522e commit d1eb96e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/AnnotatedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,33 +278,40 @@ public function optionsHookForHookAnnotations($commandInfoList)
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$state = $this->injectIntoCommandfileInstance($input, $output);
$this->commandProcessor()->interact(
$input,
$output,
$this->getNames(),
$this->annotationData
);
$state->restore();
}

protected function initialize(InputInterface $input, OutputInterface $output)
{
$state = $this->injectIntoCommandfileInstance($input, $output);
// Allow the hook manager a chance to provide configuration values,
// if there are any registered hooks to do that.
$this->commandProcessor()->initializeHook($input, $this->getNames(), $this->annotationData);
$state->restore();
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$state = $this->injectIntoCommandfileInstance($input, $output);
// Validate, run, process, alter, handle results.
return $this->commandProcessor()->process(
$result = $this->commandProcessor()->process(
$output,
$this->getNames(),
$this->commandCallback,
$this->createCommandData($input, $output)
);
$state->restore();
return $result;
}

/**
Expand All @@ -315,6 +322,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
public function processResults(InputInterface $input, OutputInterface $output, $results)
{
$state = $this->injectIntoCommandfileInstance($input, $output);
$commandData = $this->createCommandData($input, $output);
$commandProcessor = $this->commandProcessor();
$names = $this->getNames();
Expand All @@ -323,12 +331,14 @@ public function processResults(InputInterface $input, OutputInterface $output, $
$results,
$commandData
);
return $commandProcessor->handleResults(
$status = $commandProcessor->handleResults(
$output,
$names,
$results,
$commandData
);
$state->restore();
return $status;
}

protected function createCommandData(InputInterface $input, OutputInterface $output)
Expand All @@ -351,4 +361,16 @@ protected function createCommandData(InputInterface $input, OutputInterface $out

return $commandData;
}

/**
* Inject $input and $output into the command instance if it is set up to receive them.
*
* @param callable $commandCallback
* @param CommandData $commandData
* @return State
*/
public function injectIntoCommandfileInstance(InputInterface $input, OutputInterface $output)
{
return StateHelper::injectIntoCallbackObject($this->commandCallback, $input, $output);
}
}

0 comments on commit d1eb96e

Please sign in to comment.