has() public method

public has ( string $identifier, string $typeIdentifier ) : boolean
$identifier string
$typeIdentifier string
return boolean
Example #1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new AddCodeFormSubscriber())->add('translations', ResourceTranslationsType::class, ['entry_type' => $this->attributeTranslationType, 'label' => 'sylius.form.attribute.translations'])->add('type', AttributeTypeChoiceType::class, ['label' => 'sylius.form.attribute.type', 'disabled' => true]);
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         $attribute = $event->getData();
         if (!$attribute instanceof AttributeInterface) {
             return;
         }
         if (!$this->formTypeRegistry->has($attribute->getType(), 'configuration')) {
             return;
         }
         $event->getForm()->add('configuration', $this->formTypeRegistry->get($attribute->getType(), 'configuration'), ['auto_initialize' => false, 'label' => 'sylius.form.attribute_type.configuration']);
     });
 }
 /**
  * @param FormInterface $form
  * @param string $calculatorName
  * @param array $data
  */
 protected function addConfigurationFields(FormInterface $form, $calculatorName, array $data = [])
 {
     /** @var CalculatorInterface $calculator */
     $calculator = $this->calculatorRegistry->get($calculatorName);
     $calculatorType = $calculator->getType();
     if (!$this->formTypeRegistry->has($calculatorType, 'default')) {
         return;
     }
     $configurationField = $this->factory->createNamed('configuration', $this->formTypeRegistry->get($calculatorType, 'default'), $data, ['auto_initialize' => false]);
     $form->add($configurationField);
 }
Example #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);
 }