public function interactWith(FormInterface $form, HelperSet $helperSet, InputInterface $input, OutputInterface $output)
 {
     if (FormUtil::isTypeInAncestry($form, 'button')) {
         throw new NoNeedToInteractWithForm();
     }
     // by default, we let another interactor interact with this form
     throw new CanNotInteractWithForm();
 }
 /**
  * @param FormInterface $form
  *
  * @throws CouldNotResolveTransformer
  *
  * @return FormToQuestionTransformer
  */
 public function resolve(FormInterface $form)
 {
     $types = FormUtil::typeAncestry($form);
     foreach ($types as $type) {
         if (isset($this->transformers[$type])) {
             return $this->transformers[$type];
         }
     }
     throw new CouldNotResolveTransformer(sprintf('Could not find a transformer for any of these types (%s)', implode(', ', $types)));
 }
 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::isCompound($form)) {
         throw new CanNotInteractWithForm('Expected a compound form');
     }
     $submittedData = [];
     foreach ($form->all() as $name => $field) {
         try {
             $submittedData[$name] = $this->formInteractor->interactWith($field, $helperSet, $input, $output);
         } catch (NoNeedToInteractWithForm $exception) {
             continue;
         }
     }
     return $submittedData;
 }
 /**
  * @param string|\Symfony\Component\Form\FormTypeInterface $formType
  * @param array                                            &$resources
  *
  * @return InputDefinition
  */
 public function createForFormType($formType, array &$resources = [])
 {
     $resources[] = new FileResource(__FILE__);
     $form = $this->formFactory->create($formType);
     $actualFormType = $form->getConfig()->getType()->getInnerType();
     $reflection = new \ReflectionObject($actualFormType);
     $resources[] = new FileResource($reflection->getFileName());
     $inputDefinition = new InputDefinition();
     foreach ($form->all() as $name => $field) {
         if (!$this->isFormFieldSupported($field)) {
             continue;
         }
         $type = InputOption::VALUE_REQUIRED;
         $default = $field->getConfig()->getOption('data', null);
         $description = FormUtil::label($field);
         $inputDefinition->addOption(new InputOption($name, null, $type, $description, $default));
     }
     return $inputDefinition;
 }
 protected function questionFrom(FormInterface $form)
 {
     $question = FormUtil::label($form);
     return $this->formattedQuestion($question, $this->defaultValueFrom($form));
 }
 /**
  * @param FormInterface   $form
  * @param OutputInterface $output
  */
 private function printHeader(FormInterface $form, OutputInterface $output)
 {
     $output->writeln(strtr('<fieldset>{label}</fieldset>', ['{label}' => FormUtil::label($form)]));
 }