Skip to content

Commit

Permalink
Enable dependency inyectionin autowire commands (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
enzolutions authored and jmolivas committed Sep 22, 2016
1 parent e745af9 commit d9a7478
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,15 @@ private function registerCommandsFromAutoWireConfiguration()
$autoWireForcedCommand['class']
);

$command = $reflectionClass->newInstance();
$arguments = [];
if (array_key_exists('arguments', $autoWireForcedCommand)) {
foreach ($autoWireForcedCommand['arguments'] as $argument) {
$argument = substr($argument, 1);
$arguments[] = $this->container->get($argument);
}
}

$command = $reflectionClass->newInstanceArgs($arguments);

if (method_exists($command, 'setTranslator')) {
$command->setTranslator(
Expand Down

0 comments on commit d9a7478

Please sign in to comment.