/** * {@inheritdoc} * * Expected data input format : "family_code" */ public function setFieldData(ProductInterface $product, $field, $data, array $options = []) { $this->checkData($field, $data); if (null !== $data && '' !== $data) { $family = $this->getFamily($data); if (null === $family) { throw InvalidArgumentException::expected($field, 'existing family code', 'setter', 'family', $data); } $product->setFamily($family); } else { $product->setFamily(null); } }
function it_adds_products_to_the_selected_family_when_performing_the_operation(AbstractQuery $query, Family $mugs, ProductInterface $product1, ProductInterface $product2) { $this->setFamily($mugs); $this->setObjectsToMassEdit([$product1, $product2]); $product1->setFamily($mugs)->shouldBeCalled(); $product2->setFamily($mugs)->shouldBeCalled(); $this->perform(); }
/** * Denormalize the product family * * @param string $data * @param string $format * @param array $context * @param ProductInterface $product */ protected function denormalizeFamily($data, $format, array $context, ProductInterface $product) { if (strlen($data) > 0) { $family = $this->serializer->denormalize($data, $this->familyClass, $format, $context); } else { $family = null; } $product->setFamily($family); }
/** * {@inheritdoc} */ protected function doPerform(ProductInterface $product) { $product->setFamily($this->family); }
function it_empty_family_field($familyRepository, ProductInterface $product, FamilyInterface $shirt) { $product->setFamily(null)->shouldBeCalled(); $this->setFieldData($product, 'family', null); }