當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AttributeInterface::getDefaultMetricUnit方法代碼示例

本文整理匯總了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;
 }
開發者ID:vpetrovych,項目名稱:pim-community-dev,代碼行數:32,代碼來源:AttributeNormalizer.php

示例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);
 }
開發者ID:noglitchyo,項目名稱:pim-community-dev,代碼行數:17,代碼來源:AttributeNormalizerSpec.php

示例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([]);
 }
開發者ID:noglitchyo,項目名稱:pim-community-dev,代碼行數:19,代碼來源:BaseEmptyValueProviderSpec.php


注:本文中的Pim\Bundle\CatalogBundle\Model\AttributeInterface::getDefaultMetricUnit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。