/** * @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)])); }