@@ -85,16 +85,25 @@ private function askQuestions(array &$vars): void {
85
85
} while ($ library !== NULL );
86
86
87
87
$ vars ['component_libraries ' ] = \array_filter ($ vars ['component_libraries ' ]);
88
- $ vars ['component_has_css ' ] = $ ir ->confirm ('Needs CSS? ' );
89
- $ vars ['component_has_js ' ] = $ ir ->confirm ('Needs JS? ' );
90
- if ($ ir ->confirm ('Needs component props? ' )) {
88
+ $ vars ['component_has_css ' ] = $ ir ->confirm ('Need CSS? ' );
89
+ $ vars ['component_has_js ' ] = $ ir ->confirm ('Need JS? ' );
90
+ if ($ ir ->confirm ('Need component props? ' )) {
91
91
$ vars ['component_props ' ] = [];
92
92
do {
93
93
$ prop = $ this ->askProp ($ vars , $ ir );
94
94
$ vars ['component_props ' ][] = $ prop ;
95
95
} while ($ ir ->confirm ('Add another prop? ' ));
96
96
}
97
97
$ vars ['component_props ' ] = \array_filter ($ vars ['component_props ' ] ?? []);
98
+
99
+ if ($ ir ->confirm ('Need slots? ' )) {
100
+ $ vars ['component_slots ' ] = [];
101
+ do {
102
+ $ slot = $ this ->askSlot ($ vars , $ ir );
103
+ $ vars ['component_slots ' ][] = $ slot ;
104
+ } while ($ ir ->confirm ('Add another slot? ' ));
105
+ }
106
+ $ vars ['component_slots ' ] = \array_filter ($ vars ['component_slots ' ] ?? []);
98
107
}
99
108
100
109
/**
@@ -191,4 +200,22 @@ protected function askProp(array $vars, Interviewer $ir): array {
191
200
return $ prop ;
192
201
}
193
202
203
+ /**
204
+ * Asks for multiple questions to define a slot.
205
+ *
206
+ * @psalm-param array{component_machine_name: mixed, ...<array-key, mixed>} $vars
207
+ * The answers to the CLI questions.
208
+ *
209
+ * @return array
210
+ * The slot data, if any.
211
+ */
212
+ protected function askSlot (array $ vars , Interviewer $ ir ): array {
213
+ $ slot = [];
214
+ $ slot ['title ' ] = $ ir ->ask ('Slot title ' , '' , new Required ());
215
+ $ default = Utils::human2machine ($ slot ['title ' ]);
216
+ $ slot ['name ' ] = $ ir ->ask ('Slot machine name ' , $ default , new RequiredMachineName ());
217
+ $ slot ['description ' ] = $ ir ->ask ('Slot description (optional) ' );
218
+ return $ slot ;
219
+ }
220
+
194
221
}
0 commit comments