protected function selectMagentoVersion(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('magentoVersion') == null && $input->getOption('magentoVersionByName') == null) {
$question = array();
foreach ($this->commandConfig['magento-packages'] as $key => $package) {
$question[] = '<comment>' . str_pad('[' . ($key + 1) . ']', 4, ' ') . '</comment> ' . $package['name'] . "\n";
}
$question[] = "<question>Choose a magento version:</question> ";
$commandConfig = $this->commandConfig;
$type = $this->getHelper('dialog')->askAndValidate($output, $question, function ($typeInput) use($commandConfig) {
if (!in_array($typeInput, range(1, count($commandConfig['magento-packages'])))) {
throw new InvalidArgumentException('Invalid type');
}
return $typeInput;
});
} else {
$type = null;
if ($input->getOption('magentoVersion')) {
$type = $input->getOption('magentoVersion');
if ($type !== (string) (int) $type) {
$type = $this->getPackageNumberByName($type);
}
} elseif ($input->getOption('magentoVersionByName')) {
$type = $this->getPackageNumberByName($input->getOption('magentoVersionByName'));
}
if ($type == null) {
throw new InvalidArgumentException('Unable to locate Magento version');
}
}
$magentoPackages = $this->commandConfig['magento-packages'];
$index = $type - 1;
if (!isset($magentoPackages[$index])) {
throw new InvalidArgumentException(sprintf('Invalid Magento package number %s, must be from 1 to %d.', var_export($type, true), count($magentoPackages)));
}
$this->config['magentoVersionData'] = $magentoPackages[$index];
}