本文整理匯總了PHP中Pim\Component\Catalog\Model\ProductInterface::setFamily方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProductInterface::setFamily方法的具體用法?PHP ProductInterface::setFamily怎麽用?PHP ProductInterface::setFamily使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Pim\Component\Catalog\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::setFamily方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setFieldData
/**
* {@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);
}
}
示例2:
function it_empty_family_field($familyRepository, ProductInterface $product, FamilyInterface $shirt)
{
$product->setFamily(null)->shouldBeCalled();
$this->setFieldData($product, 'family', null);
}
示例3: denormalizeFamily
/**
* 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);
}