Skip to content

Commit

Permalink
[console] Load command aliases. (#3413)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Jul 9, 2017
1 parent 030bdbe commit d4acb53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
30 changes: 13 additions & 17 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,11 @@ private function registerCommands()
->get('console.annotation_validator');
}

// $aliases = $this->container->get('console.configuration_manager')
// ->getConfiguration()
// ->get('application.commands.aliases')?:[];
$aliases = $this->container->get('console.configuration_manager')
->getConfiguration()
->get('application.commands.aliases')?:[];

foreach ($consoleCommands as $name) {
AnnotationRegistry::reset();
AnnotationRegistry::registerLoader(
[
$this->container->get('class_loader'),
"loadClass"
]
);

if (!$this->container->has($name)) {
continue;
Expand Down Expand Up @@ -212,13 +205,16 @@ private function registerCommands()
);
}

// if (array_key_exists($command->getName(), $aliases)) {
// $commandAliases = $aliases[$command->getName()];
// if (!is_array($commandAliases)) {
// $commandAliases = [$commandAliases];
// }
// $command->setAliases($commandAliases);
// }
if (array_key_exists($command->getName(), $aliases)) {
$commandAliases = array_merge(
$command->getAliases(),
$aliases[$command->getName()]
);
if (!is_array($commandAliases)) {
$commandAliases = [$commandAliases];
}
$command->setAliases($commandAliases);
}

$this->add($command);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Debug/ContainerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function configure()
InputArgument::OPTIONAL,
$this->trans('commands.debug.container.arguments.arguments')
)
->setAliases(['cod']);
->setAliases(['dco']);
}

/**
Expand Down

0 comments on commit d4acb53

Please sign in to comment.