/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new BuildShippingMethodFormListener($this->calculatorRegistry, $builder->getFormFactory()))->add('translations', 'a2lix_translationsForms', array('form_type' => 'sylius_shipping_method_translation', 'label' => 'sylius.form.shipping_method.name'))->add('enabled', 'checkbox', array('required' => false, 'label' => 'sylius.form.shipping_method.enabled'))->add('category', 'sylius_shipping_category_choice', array('required' => false, 'label' => 'sylius.form.shipping_method.category'))->add('categoryRequirement', 'choice', array('choices' => ShippingMethod::getCategoryRequirementLabels(), 'multiple' => false, 'expanded' => true, 'label' => 'sylius.form.shipping_method.category_requirement'))->add('calculator', 'sylius_shipping_calculator_choice', array('label' => 'sylius.form.shipping_method.calculator'));
     $prototypes = array();
     $prototypes['rules'] = array();
     foreach ($this->checkerRegistry->getCheckers() as $type => $checker) {
         $prototypes['rules'][$type] = $builder->create('__name__', $checker->getConfigurationFormType())->getForm();
     }
     $prototypes['calculators'] = array();
     foreach ($this->calculatorRegistry->getCalculators() as $name => $calculator) {
         if (!$calculator->isConfigurable()) {
             continue;
         }
         $prototypes['calculators'][$name] = $builder->create('configuration', $calculator->getConfigurationFormType())->getForm();
     }
     $builder->setAttribute('prototypes', $prototypes);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new BuildShippingMethodFormSubscriber($this->calculatorRegistry, $builder->getFormFactory(), $this->formRegistry))->addEventSubscriber(new AddCodeFormSubscriber())->add('translations', 'sylius_translations', ['type' => 'sylius_shipping_method_translation', 'label' => 'sylius.form.shipping_method.translations'])->add('category', 'sylius_shipping_category_choice', ['required' => false, 'empty_value' => 'sylius.ui.no_requirement', 'label' => 'sylius.form.shipping_method.category'])->add('categoryRequirement', 'choice', ['choices' => ShippingMethod::getCategoryRequirementLabels(), 'multiple' => false, 'expanded' => true, 'label' => 'sylius.form.shipping_method.category_requirement'])->add('calculator', 'sylius_shipping_calculator_choice', ['label' => 'sylius.form.shipping_method.calculator'])->add('enabled', 'checkbox', ['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) {
         $calculatorTypeName = sprintf('sylius_shipping_calculator_%s', $calculator->getType());
         if (!$this->formRegistry->hasType($calculatorTypeName)) {
             continue;
         }
         $prototypes['calculators'][$name] = $builder->create('configuration', $calculatorTypeName)->getForm();
     }
     $builder->setAttribute('prototypes', $prototypes);
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 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);
 }
Exemple #4
0
 public function __construct()
 {
     parent::__construct();
     $this->channels = new ArrayCollection();
 }