protected function askPluginNameAndValidate(InputInterface $input, OutputInterface $output, $pluginNames, $invalidArgumentException)
{
$validate = function ($pluginName) use($pluginNames, $invalidArgumentException) {
if (!in_array($pluginName, $pluginNames)) {
throw new \InvalidArgumentException($invalidArgumentException);
}
return $pluginName;
};
$pluginName = $input->getOption('pluginname');
if (empty($pluginName)) {
$dialog = $this->getHelperSet()->get('dialog');
$pluginName = $dialog->askAndValidate($output, 'Enter the name of your plugin: ', $validate, false, null, $pluginNames);
} else {
$validate($pluginName);
}
return $pluginName;
}