@param StagedFormObject $formObject

@return static
354716
public function forInstance(StagedFormObject $formObject)
    {
        $self                  = new self($formObject, $this->defineStageCallbacks);
        $self->knownProperties = $this->knownProperties;

        return $self;
    }
293378
public function renderFormJavascriptPrototypes(array $context, FormView $rootView)
    {
        if (!isset($rootView->vars['prototype'])) {
            throw new \InvalidArgumentException('The given root form view has no prototype');
        }

        $stack = [
            // FormView $prototype, string $prototypeName, string[] $parentPrototypeNames
            [$rootView->vars['prototype'], $rootView->vars['prototype']->vars['name'], []],
        ];

        $output = '[';
        $counter = 0;

        while (list($prototype, $prototypeName, $parentPrototypeNames) = \array_pop($stack)) {
            try {
                // the "unique_block_prefix" must be changed to prevent messing
                // up FormRenderer's internal cache and causing errors later on
                $prototype->vars['unique_block_prefix'] .= \sprintf('_%d', ++$this->prototypeRenderUidSeq);

                if (isset($prototype->vars['prototype'])) {
                    // directly nested collection prototypes lead to recursion in searchAndRenderBlock()
                    throw new \RuntimeException('Directly nested collections with prototypes are not supported. Add an intermediate type or disable prototypes.');
                }
                $code = $this->renderer->searchAndRenderBlock($prototype, 'javascript_prototype', $context);

                if (++$counter > 1) {
                    $output .= ",\n";
                }

                $output .= \sprintf(
                    '{id: %s, prototypeName: %s, parentPrototypeNames: %s, initializer: function ($field) { %s }}',
                    \json_encode($prototype->vars['id']),
                    \json_encode($prototypeName),
                    \json_encode($parentPrototypeNames),
                    $code
                );
            } catch (\LogicException $e) {
                foreach ($prototype->children as $child) {
                    $stack[] = isset($child->vars['prototype'])
                        ? [
                            $child->vars['prototype'],
                            $child->vars['prototype']->vars['name'],
                            \array_merge($parentPrototypeNames, [$prototypeName]),
                        ]
                        : [
                            $child,
                            $prototypeName,
                            $parentPrototypeNames,
                        ];
                }
            }
        }

        $output .= ']';

        return $output;
    }
819138
public function create($formType, InputInterface $input, array $options = [])
    {
        $options = $this->addDefaultOptions($options);

        $formBuilder = $this->formFactory->createBuilder(FormUtil::formTypeToString($formType), null, $options);

        foreach ($formBuilder as $name => $childBuilder) {
            /* @var FormBuilderInterface $childBuilder */
            if (!$input->hasOption($name)) {
                continue;
            }

            $providedValue = $input->getOption($name);
            if ($providedValue === null) {
                continue;
            }

            $childBuilder->setData($providedValue);
        }

        return $formBuilder->getForm();
    }
233466
public function defineFormStage(StagedFormObject $instance) : \Dms\Core\Form\Object\FinalizedFormObjectDefinition
    {
        return call_user_func($this->defineFormStageCallback, $instance);
    }
1143460
public function setFormFieldType($formFieldType)
    {
        if (!is_string($formFieldType) || $formFieldType === '') {
            throw new InvalidArgumentException('"Form field type" argument must be a string and must not empty.');
        }

        $this->formFieldType = $formFieldType;

        return $this;
    }
582070
public function banProductPageCacheCheckStock($eventObject) {
        if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) {
            $item = $eventObject->getItem();
            if ($item->getStockStatusChangedAutomatically() ||
                    ($item->getOriginalInventoryQty() <= 0 &&
                        $item->getQty() > 0 &&
                        $item->getQtyCorrection() > 0)) {
                $banHelper = Mage::helper('turpentine/ban');
                $cronHelper = Mage::helper('turpentine/cron');
                $product = Mage::getModel('catalog/product')
                    ->load($item->getProductId());
                $urlPattern = $banHelper->getProductBanRegex($product);
                $result = $this->_getVarnishAdmin()->flushUrl($urlPattern);
                Mage::dispatchEvent('turpentine_ban_product_cache_check_stock',
                    $result);
                if ($this->_checkResult($result) &&
                        $cronHelper->getCrawlerEnabled()) {
                    $cronHelper->addProductToCrawlerQueue($product);
                    foreach ($banHelper->getParentProducts($product)
                            as $parentProduct) {
                        $cronHelper->addProductToCrawlerQueue($parentProduct);
                    }
                }
            }
        }
    }
43992
public function getFormConfiguration($formClassName)
    {
        $formzConfiguration = $this->getExtensionConfiguration();

        return (isset($formzConfiguration['forms'][$formClassName]))
            ? $formzConfiguration['forms'][$formClassName]
            : [];
    }
1039808
public function mapFormSubmissionToDto(array $submission)
    {
        $stagedFormObject = $this->stagedFormObject->submitNew($submission);

        return new ObjectActionParameter(
                $stagedFormObject->getObject(),
                $stagedFormObject
        );
    }
614513
protected function renderFormActions()
    {
        $rowPlugin = $this->getRowPlugin();

        if (!empty($this->formActionElements)) {
            $this->getElement()->addChild($rowPlugin($this->formActionElements, true)->getElement());
        }

        return $this;
    }
4902
public function getMediaBuilder($formMapper)
    {
        $admin_pool = $this->getContainer()->get('sonata.admin.pool');

        $admin = $admin_pool->getAdminByAdminCode('compo_core.admin.settings');
        // simulate an association ...
        $fieldDescription = $this->getMediaAdmin()->getModelManager()->getNewFieldDescriptionInstance(
            $this->mediaAdmin->getClass(),
            'media',
            [
                'translation_domain' => 'SonataMediaBundle',
            ]
        );
        $fieldDescription->setAssociationAdmin($this->getMediaAdmin());
        $fieldDescription->setAdmin($admin);
        $fieldDescription->setOption('edit', 'list');
        $fieldDescription->setAssociationMapping(
            [
                'fieldName' => 'media',
                'type' => ClassMetadataInfo::MANY_TO_ONE,
            ]
        );

        return $formMapper->add(
            'mediaId',
            'sonata_type_model_list',
            [
                'sonata_field_description' => $fieldDescription,
                'class' => $this->getMediaAdmin()->getClass(),
                'model_manager' => $this->getMediaAdmin()->getModelManager(),
                'label' => 'form.label_media',
                'required' => false,
            ]
        );
    }
397427
private function getFormInterface(FormInterface $form, $id): FormInterface
    {
        $name = $form->getName();
        if ($id === $name)
            return $form;
        if (mb_strpos($id, $name.'_') === 0) {
            $id = mb_substr($id, mb_strlen($name . '_'));
            foreach ($form->all() as $name => $child) {
                if ($id === $name)
                    return $child;
                if (mb_strpos($id, $name.'_') === 0)
                    return $this->getFormInterface($child, $id);
            }
        }
        return $form;
    }
319943
public static function getFormRoot($formView)
    {
        $parent = $formView;
        while (isset($parent->parent)) {
            $parent = $parent->parent;
        }
        return $parent;
    }
907781
public static function begin($firstStageForm) : StagedForm
    {
        $firstStage = self::parseStage($firstStageForm);

        if (!($firstStage instanceof IndependentFormStage)) {
            throw InvalidArgumentException::format(
                    'Invalid form stage argument: first stage must be independent, callable with required parameter given'
            );
        }

        return new self($firstStage);
    }
1229673
public function renderFormBasketElementAction(FormView $formView, BasketElementInterface $basketElement, BasketInterface $basket)
    {
        $provider = $this->get('sonata.product.pool')->getProvider($basketElement->getProduct());

        return $this->render(sprintf('%s:form_basket_element.html.twig', $provider->getBaseControllerName()), [
            'formView' => $formView,
            'basketElement' => $basketElement,
            'basket' => $basket,
        ]);
    }
409501
public function addResponse(FormResponse $response)
    {
        if ($this->responses->contains($response) === false) {
            $response->setForm($this);
            $this->responses->add($response);
        }

        return $this;
    }
1005048
public function removeResponse(FormResponse $response)
    {
        if ($this->responses->contains($response) === true) {
            $response->setForm(null);
            $this->responses->removeElement($response);
        }

        return $this;
    }
309962
public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence)
    {
        $sfsf = new StringFormSubmissionField();
        $sfsf->setFieldName('field_' . $this->getUniqueId());
        $sfsf->setLabel($this->getLabel());
        $sfsf->setSequence($sequence);

        $data = $formBuilder->getData();
        $data['formwidget_' . $this->getUniqueId()] = $sfsf;

        $constraints = array();
        if ($this->getRequired()) {
            $options = array();
            if (!empty($this->errorMessageRequired)) {
                $options['message'] = $this->errorMessageRequired;
            }
            $constraints[] = new NotBlank($options);
        }
        if ($this->getRegex()) {
            $options = array('pattern' => $this->getRegex());
            if (!empty($this->errorMessageRegex)) {
                $options['message'] = $this->errorMessageRegex;
            }
            $constraints[] = new Regex($options);
        }

        $formBuilder->add('formwidget_' . $this->getUniqueId(),
            StringFormSubmissionType::class,
            array(
                'label' => $this->getLabel(),
                'constraints' => $constraints,
                'required' => $this->getRequired(),
            )
        );
        $formBuilder->setData($data);

        $fields->append($sfsf);
    }