本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\AttributeInterface::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::getData方法的具体用法?PHP AttributeInterface::getData怎么用?PHP AttributeInterface::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\AttributeInterface
的用法示例。
在下文中一共展示了AttributeInterface::getData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate metric type and default metric unit
*
* @param AttributeInterface|MetricInterface|ProductValueInterface $object
* @param Constraint $constraint
*/
public function validate($object, Constraint $constraint)
{
if ($object instanceof AttributeInterface) {
$familyProperty = 'metricFamily';
$unitProperty = 'defaultMetricUnit';
} elseif ($object instanceof MetricInterface && null !== $object->getData()) {
$familyProperty = 'family';
$unitProperty = 'unit';
} elseif ($object instanceof ProductValueInterface && null !== $object->getMetric() && (null !== $object->getMetric()->getUnit() || null !== $object->getMetric()->getData())) {
$object = $object->getMetric();
$familyProperty = 'family';
$unitProperty = 'unit';
} else {
return;
}
$family = $this->propertyAccessor->getValue($object, $familyProperty);
$unit = $this->propertyAccessor->getValue($object, $unitProperty);
if (!array_key_exists($family, $this->measures)) {
$this->context->buildViolation($constraint->familyMessage)->atPath($familyProperty)->addViolation();
} elseif (!array_key_exists($unit, $this->measures[$family]['units'])) {
$this->context->buildViolation($constraint->unitMessage)->atPath($unitProperty)->addViolation();
}
}