public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber($this->buildShippingMethodFormSubscriber)->addEventSubscriber(new AddCodeFormSubscriber())->add('translations', ResourceTranslationsType::class, ['entry_type' => $this->shippingMethodTranslationType, 'label' => 'sylius.form.shipping_method.translations'])->add('position', IntegerType::class, ['required' => false, 'label' => 'sylius.form.shipping_method.position'])->add('category', ShippingCategoryChoiceType::class, ['required' => false, 'placeholder' => 'sylius.ui.no_requirement', 'label' => 'sylius.form.shipping_method.category'])->add('categoryRequirement', ChoiceType::class, ['choices' => array_flip(ShippingMethod::getCategoryRequirementLabels()), 'multiple' => false, 'expanded' => true, 'label' => 'sylius.form.shipping_method.category_requirement'])->add('calculator', CalculatorChoiceType::class, ['label' => 'sylius.form.shipping_method.calculator'])->add('enabled', CheckboxType::class, ['label' => 'sylius.form.locale.enabled']);
$prototypes = ['rules' => [], 'calculators' => []];
/** @var RuleCheckerInterface $checker */
foreach ($this->checkerRegistry->all() as $type => $checker) {
$prototypes['rules'][$type] = $builder->create('__name__', $checker->getConfigurationFormType())->getForm();
}
/** @var CalculatorInterface $calculator */
foreach ($this->calculatorRegistry->all() as $name => $calculator) {
$calculatorType = $calculator->getType();
if (!$this->formTypeRegistry->has($calculatorType, 'default')) {
continue;
}
$form = $builder->create('configuration', $this->formTypeRegistry->get($calculatorType, 'default'));
$prototypes['calculators'][$name] = $form->getForm();
}
$builder->setAttribute('prototypes', $prototypes);
}