function it_creates_new_values_only_for_non_existing_attributes($attributeValueFactory, ArchetypeInterface $archetype, ArchetypeSubjectInterface $subject, AttributeInterface $attribute, AttributeValueInterface $attributeValue, OptionInterface $option) { $archetype->getAttributes()->willReturn(array($attribute))->shouldBeCalled(); $archetype->getOptions()->willReturn(array($option))->shouldBeCalled(); $attribute->getName()->willReturn('test'); $subject->getAttributeByName('test')->shouldBeCalled()->willReturn($attributeValue); $attributeValueFactory->createNew()->shouldNotBeCalled(); $attributeValue->setAttribute($attribute)->shouldNotBeCalled(); $subject->getArchetype()->willReturn($archetype); $subject->addAttribute(Argument::any())->shouldNotBeCalled(); $subject->addOption($option)->shouldBeCalled(); $this->build($subject); }
/** * @param FormInterface $form * @param AttributeInterface $attribute */ protected function addValueField(FormInterface $form, AttributeInterface $attribute) { $form->add('value', $this->formTypeRegistry->get($attribute->getType(), 'default'), ['auto_initialize' => false, 'label' => $attribute->getName()]); }
/** * @param FormInterface $form * @param AttributeInterface $attribute */ private function addValueField(FormInterface $form, AttributeInterface $attribute) { $options = array('auto_initialize' => false, 'label' => $attribute->getName()); $form->add('value', 'sylius_attribute_type_' . $attribute->getType(), $options); }
function it_returns_its_attribute_name(AttributeInterface $attribute) { $attribute->getName()->willReturn('T-Shirt material'); $this->setAttribute($attribute); $this->getName()->shouldReturn('T-Shirt material'); }
/** * @param AttributeInterface $attribute * * @return FormView */ private function getAttributeForm(AttributeInterface $attribute) { $attributeForm = 'sylius_attribute_type_' . $attribute->getType(); $form = $this->get('form.factory')->createNamed('value', $attributeForm, null, ['label' => $attribute->getName()]); return $form->createView(); }
/** * @param AttributeInterface $attribute * * @return FormView */ protected function getAttributeForm(AttributeInterface $attribute) { $attributeForm = $this->get('sylius.form_registry.attribute_type')->get($attribute->getType(), 'default'); $form = $this->get('form.factory')->createNamed('value', $attributeForm, null, ['label' => $attribute->getName()]); return $form->createView(); }