public function interactWith(FormInterface $form, HelperSet $helperSet, InputInterface $input, OutputInterface $output)
{
if (!$input->isInteractive()) {
throw new CanNotInteractWithForm('This interactor only works with interactive input');
}
if (!FormUtil::isTypeInAncestry($form, CollectionType::class)) {
throw new CanNotInteractWithForm('Expected a "collection" form');
}
if (!$form->getConfig()->getOption('allow_add')) {
throw new FormNotReadyForInteraction('The "collection" form should have the option "allow_add"');
}
$this->printHeader($form, $output);
$submittedData = [];
$prototype = $form->getConfig()->getAttribute('prototype');
while ($this->askIfContinueToAdd($helperSet, $input, $output)) {
$submittedData[] = $this->formInteractor->interactWith($prototype, $helperSet, $input, $output);
}
return $submittedData;
}