本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\AttributeInterface::getDefaultMetricUnit方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::getDefaultMetricUnit方法的具体用法?PHP AttributeInterface::getDefaultMetricUnit怎么用?PHP AttributeInterface::getDefaultMetricUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\AttributeInterface
的用法示例。
在下文中一共展示了AttributeInterface::getDefaultMetricUnit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEmptyValue
/**
* Get empty value for specified attribute depending on its type
*
* @param AttributeInterface $attribute
*
* @return array|bool|string|null
*/
protected function getEmptyValue(AttributeInterface $attribute)
{
switch ($attribute->getAttributeType()) {
case 'pim_catalog_metric':
$emptyValue = ['data' => null, 'unit' => $attribute->getDefaultMetricUnit()];
break;
case 'pim_catalog_multiselect':
case 'pim_reference_data_multiselect':
$emptyValue = [];
break;
case 'pim_catalog_text':
$emptyValue = '';
break;
case 'pim_catalog_boolean':
$emptyValue = false;
break;
case 'pim_catalog_price_collection':
$emptyValue = [];
break;
default:
$emptyValue = null;
break;
}
return $emptyValue;
}
示例2: let
function let(TranslationNormalizer $transnormalizer, AttributeInterface $attribute, AttributeGroupInterface $attributeGroup)
{
$this->beConstructedWith($transnormalizer);
$transnormalizer->normalize(Argument::cetera())->willReturn([]);
$attribute->getAttributeType()->willReturn('Yes/No');
$attribute->getCode()->willReturn('attribute_size');
$attribute->getGroup()->willReturn($attributeGroup);
$attributeGroup->getCode()->willReturn('size');
$attribute->isUnique()->willReturn(true);
$attribute->isUseableAsGridFilter()->willReturn(false);
$attribute->getAllowedExtensions()->willReturn(['csv', 'xml', 'json']);
$attribute->getMetricFamily()->willReturn('Length');
$attribute->getDefaultMetricUnit()->willReturn('Centimenter');
$attribute->getReferenceDataName()->willReturn('color');
$attribute->isLocalizable()->willReturn(true);
$attribute->isScopable()->willReturn(false);
}
示例3:
function it_should_provide_the_empty_value_for_the_given_attribute(AttributeInterface $attribute)
{
$attribute->getAttributeType()->willReturn('pim_catalog_metric');
$attribute->getDefaultMetricUnit()->willReturn('METER');
$this->supports($attribute)->shouldReturn(true);
$this->getEmptyValue($attribute)->shouldReturn(['data' => null, 'unit' => 'METER']);
$attribute->getAttributeType()->willReturn('pim_catalog_multiselect');
$this->supports($attribute)->shouldReturn(true);
$this->getEmptyValue($attribute)->shouldReturn([]);
$attribute->getAttributeType()->willReturn('pim_catalog_text');
$this->supports($attribute)->shouldReturn(true);
$this->getEmptyValue($attribute)->shouldReturn('');
$attribute->getAttributeType()->willReturn('pim_catalog_boolean');
$this->supports($attribute)->shouldReturn(true);
$this->getEmptyValue($attribute)->shouldReturn(false);
$attribute->getAttributeType()->willReturn('pim_catalog_price_collection');
$this->supports($attribute)->shouldReturn(true);
$this->getEmptyValue($attribute)->shouldReturn([]);
}