Appends a form that matches the characteristic type.

@param \Symfony\Component\Form\FormInterface $form
@param \Ekyna\Component\Characteristics\Schema\Definition $definition
344259
private function appendProperForm(FormInterface $form, Definition $definition)
    {
        $identifier = $definition->getIdentifier();
        if ($form->has($identifier)) {
            return;
        }

        $type = sprintf('ekyna_%s_characteristic', $definition->getType());
        $options = array();
        if ($definition->getType() == 'choice') {
            $options['identifier'] = $identifier;
        }

        $parentData = null;
        if (null !== $this->parentDatas && null !== $characteristic = $this->parentDatas->findCharacteristicByIdentifier($identifier)) {
            $parentData = $characteristic->display($definition);
        }

        $form->add($identifier, $type, array_merge(array(
            'property_path' => '[' . $identifier . ']',
            'label' => $definition->getTitle(),
            'parent_data' => $parentData,
        ), $options));
    }
869175
private function buildId(FormInterface $form)
    {
        $id = $form->getName();

        if (null !== $form->getParent()) {
            $id = $this->buildId($form->getParent()).'_'.$id;
        }

        return $id;
    }
1176747
private function initializeValidator($form)
    {
        if (false === $form instanceof FormInterface) {
            throw InvalidArgumentTypeException::validatingWrongFormType(get_class($form));
        }

        $this->form = $form;
        $this->result = new FormResult;
        $this->formValidatorExecutor = $this->getFormValidatorExecutor($form);
    }
521413
public function addForm(FormObject $form)
    {
        if (true === $this->hasForm($form->getClassName(), $form->getName())) {
            throw DuplicateEntryException::formWasAlreadyRegistered($form);
        }

        $form->getConfiguration()->setParents([$this]);

        $this->forms[$form->getClassName()][$form->getName()] = $form;
    }
457499
protected function submitForm(FormInterface $form, Request $request)
    {
        $bag = $request->isMethod('GET') || $form->getConfig()->getMethod() === 'GET'
            ? $request->query
            : $request->request;

        if ($this->getParameterResolver()->resolveApi()) {
            $data = array_merge($bag->all(), $request->files->all());
        } else {
            $data = array_merge($bag->get($form->getName(), []), $request->files->get($form->getName(), []));
        }

        array_walk_recursive($data, function (&$value) {
            if ($value === false) {
                $value = 'false';
            }
        });

        return $form->submit($data, !$request->isMethod('PATCH'));
    }
1015596
protected function addCommonSpecs(FormInterface $form, array $schema, $extensions = [], $widget)
    {
        $schema = $this->addLabel($form, $schema);
        $schema = $this->addAttr($form, $schema);
        $schema = $this->addPattern($form, $schema);
        $schema = $this->addDescription($form, $schema);
        $schema = $this->addWidget($form, $schema, $widget);
        $schema = $this->applyExtensions($extensions, $form, $schema);

        return $schema;
    }
1304073
protected function workout(FormInterface $form)
    {
        foreach (self::$workers as $worker) {
            call_user_func_array(
                [$worker, 'execute'],
                [$form, $this->parsedData]
            );
        }
    }
851147
protected function defaultValueFrom(FormInterface $form)
    {
        $defaultValue = $form->getData();
        if (is_array($defaultValue)) {
            $defaultValue = implode(',', $defaultValue);
        }

        return $defaultValue;
    }
421012
public function create(FormInterface $form)
    {
        $client = new ClientEntity();

        $formData = $form->getData();

        $client->setRedirectUris($formData['redirectUris']);
        $client->setAllowedGrantTypes($formData['grants']);

        $this->entityManager->persist($client);
        $this->entityManager->flush();

        return $this->createResourceFromClient($client);
    }
328866
protected function addAttr(FormInterface $form, array $schema)
    {
        if ($attr = $form->getConfig()->getOption('attr')) {
            $schema['attr'] = $attr;
        }

        return $schema;
    }
178480
protected function questionFrom(FormInterface $form)
    {
        $question = $this->translator->trans(FormUtil::label($form), [], $this->translationDomainFrom($form));

        return $this->formattedQuestion($question, $this->defaultValueFrom($form));
    }
1358940
public function buildForm(FormBuilderInterface $builder): FormInterface
    {
        $this->buildFilterForm($builder);
        $this->buildSortableForm($builder);

        $this->form = $builder->getForm();

        return $this->form;
    }
229255
private function addFormDeclaration($formTypeName)
    {
        $name = strtolower($this->model);
        $extension = $matches = preg_split('/(?=[A-Z])/', $this->bundle->getName(), -1, PREG_SPLIT_NO_EMPTY);
        $bundleName = $this->getBundlePrefix();
        array_pop($extension);
        $path = $this->bundle->getPath() . '/Resources/config/forms.xml';

        if (!file_exists($path)) {
            $this->renderFile('form/ServicesForms.xml.twig', $path, array());
            $ref = 'protected $configFiles = array(';

            $this->dumpFile(
                $this->bundle->getPath() . '/DependencyInjection/' . implode('', $extension) . 'Extension.php',
                "\n        'forms',",
                $ref
            );die;
        }

        $this->addService($path, $bundleName, $name, $formTypeName);
        $this->addParameter($path, $bundleName, $name);
    }
1209273
public function renderProfileForm(FormInterface $form = null, $widget = true)
    {
        if (empty($form)) {
            $form = $this->userFormFactory->createProfileForm();
        }

        $template = $widget
            ? 'DarvinUserBundle:User/widget:profile.html.twig'
            : 'DarvinUserBundle:User:profile.html.twig';

        return $this->templating->render($template, [
            'form' => $form->createView(),
        ]);
    }
895384
private function addContentFieldset(FormInterface $form)
    {
        $contentData = $form->addChild($this->getElement('nested_fieldset', [
            'name'  => 'content_data',
            'label' => 'common.fieldset.description',
        ]));
        
        $languageData = $contentData->addChild($this->getElement('language_fieldset', [
            'name'        => 'translations',
            'label'       => 'common.fieldset.translations',
            'transformer' => $this->getRepositoryTransformer('translation', $this->get('page.repository')),
        ]));
        
        $languageData->addChild($this->getElement('rich_text_editor', [
            'name'  => 'content',
            'label' => 'common.label.description',
        ]));
    }
808969
private function addTrashAssetField(FormInterface $form, Location $location = null): void
    {
        if ($location === null) {
            return;
        }

        $contentType = $this->contentTypeService->loadContentType(
            $location->getContentInfo()->contentTypeId
        );

        $translatorParameters = [
            '%content_name%' => $location->getContent()->getName(),
            '%content_type%' => $contentType->getName(
                $location->getContentInfo()->mainLanguageCode
            ),
        ];

        $form->add('trashAssets', ChoiceType::class, [
            'expanded' => true,
            'multiple' => false,
            'choices' => [
                /** @Desc("Delete only %content_name% (%content_type%)") */
                $this->translator->trans('location_trash_form.default_trash', $translatorParameters, 'forms') => LocationTrashWithAssetType::RADIO_SELECT_DEFAULT_TRASH,
                /** @Desc("Delete %content_name% (%content_type%) and its related image assets") */
                $this->translator->trans('location_trash_form.trash_with_asset', $translatorParameters, 'forms') => LocationTrashWithAssetType::RADIO_SELECT_TRASH_WITH_ASSETS,
            ],
        ]);
    }
53119
private function addContentFieldset(FormInterface $form)
    {
        $contentData = $form->addChild($this->getElement('nested_fieldset', [
            'name'  => 'content_data',
            'label' => $this->trans('common.fieldset.description')
        ]));

        $languageData = $contentData->addChild($this->getElement('language_fieldset', [
            'name'        => 'translations',
            'label'       => $this->trans('common.fieldset.translations'),
            'transformer' => $this->getRepositoryTransformer('translation', $this->get('page.repository'))
        ]));

        $languageData->addChild($this->getElement('rich_text_editor', [
            'name'  => 'content',
            'label' => $this->trans('common.label.description'),
        ]));

        $this->addMetadataFieldset($form, $this->get('page.repository'));
    }