You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Toolkit] Improve InstallComponentCommand by asking/guessing which Kit to use, remove ux_toolkit.kit parameter, remove DependencyInjection configuration
// If more than one kit is available, we ask the user which one to use
111
+
if (($availableKitsCount = \count($availableKits)) > 1) {
112
+
$kitName = $io->choice(null === $componentName ? 'Which kit do you want to use?' : \sprintf('The component "%s" exists in multiple kits. Which one do you want to use?', $componentName), array_map(fn (Kit$kit) => $kit->name, $availableKits));
113
+
114
+
foreach ($availableKitsas$availableKit) {
115
+
if ($availableKit->name === $kitName) {
116
+
$kit = $availableKit;
117
+
break;
118
+
}
119
+
}
120
+
} elseif (1 === $availableKitsCount) {
121
+
$kit = $availableKits[0];
122
+
} else {
123
+
$io->error('No kit found. Please provide a kit name using the --kit option.');
if (null === $componentName = $input->getArgument('component')) {
132
+
if (null === $componentName) {
99
133
// Ask for the component name if not provided
100
134
$componentName = $io->choice('Which component do you want to install?', array_map(fn (Component$component) => $component->name, $this->getAvailableComponents($kit)));
101
135
$component = $kit->getComponent($componentName);
@@ -124,7 +158,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
124
158
}
125
159
}
126
160
127
-
$io->writeln(\sprintf('Installing component <info>%s</> from the <info>%s</> kit...', $component->name, $kitName));
161
+
$io->writeln(\sprintf('Installing component <info>%s</> from the <info>%s</> kit...', $component->name, $kit->name));
0 commit comments