当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductValueInterface::getAttribute方法代码示例

本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\ProductValueInterface::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductValueInterface::getAttribute方法的具体用法?PHP ProductValueInterface::getAttribute怎么用?PHP ProductValueInterface::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Bundle\CatalogBundle\Model\ProductValueInterface的用法示例。


在下文中一共展示了ProductValueInterface::getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareValueFormData

 /**
  * {@inheritdoc}
  */
 public function prepareValueFormData(ProductValueInterface $value)
 {
     if (!is_null($value->getData())) {
         return $value->getData();
     }
     $data = $this->metricFactory->createMetric($value->getAttribute()->getMetricFamily());
     $data->setData($value->getAttribute()->getDefaultValue());
     return $data;
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:12,代码来源:MetricType.php

示例2: validateComplexValue

 /**
  * Validate a more complex value that doesn't store the data itself
  *
  * @param ProductValueInterface $value
  * @param Constraint            $constraint
  *
  * @return null
  */
 protected function validateComplexValue(ProductValueInterface $value, Constraint $constraint)
 {
     if ($value->getAttribute()) {
         $backendType = $value->getAttribute()->getBackendType();
         if ($backendType === 'prices') {
             $this->validatePrices($value, $constraint);
         } elseif ($backendType === 'media') {
             $this->validateMedia($value, $constraint);
         } elseif ($backendType === 'metric') {
             $this->validateMetric($value, $constraint);
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:21,代码来源:ProductValueCompleteValidator.php

示例3: prepareValueFormData

 /**
  * {@inheritdoc}
  */
 public function prepareValueFormData(ProductValueInterface $value)
 {
     if ($value->getData() && $value->getData()->isEmpty()) {
         return $value->getAttribute()->getDefaultValue();
     }
     $iterator = $value->getData()->getIterator();
     if (true === $value->getAttribute()->getProperty('autoOptionSorting')) {
         $iterator->uasort('strcasecmp');
     } else {
         $iterator->uasort(function ($first, $second) {
             return $first->getSortOrder() < $second->getSortOrder() ? -1 : 1;
         });
     }
     return new ArrayCollection(iterator_to_array($iterator));
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:18,代码来源:OptionMultiSelectType.php

示例4: prepareValueFormOptions

 /**
  * {@inheritdoc}
  */
 public function prepareValueFormOptions(ProductValueInterface $value)
 {
     $referenceDataConf = $this->referenceDataRegistry->get($value->getAttribute()->getReferenceDataName());
     $options = parent::prepareValueFormOptions($value);
     $options['class'] = $referenceDataConf->getClass();
     return $options;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:10,代码来源:ReferenceDataSimpleSelectType.php

示例5:

 function it_converts_metric_values_given_the_configured_base_unit_in_the_channel($converter, ProductValueInterface $weightValue, ProductValueInterface $surfaceValue, ProductValueInterface $nameValue, AttributeInterface $weight, AttributeInterface $surface, AttributeInterface $name, MetricInterface $weightMetric, MetricInterface $surfaceMetric, ProductInterface $product, ChannelInterface $channel)
 {
     $weightValue->getAttribute()->willReturn($weight);
     $weightValue->getData()->willReturn($weightMetric);
     $weight->getCode()->willReturn('weight');
     $weightMetric->getFamily()->willReturn('Weight');
     $weightMetric->getUnit()->willReturn('KILOGRAM');
     $weightMetric->getData()->willReturn(1);
     $surfaceValue->getAttribute()->willReturn($surface);
     $surfaceValue->getData()->willReturn($surfaceMetric);
     $surface->getCode()->willReturn('surface');
     $surfaceMetric->getFamily()->willReturn('Surface');
     $surfaceMetric->getUnit()->willReturn('METER_SQUARE');
     $surfaceMetric->getData()->willReturn(10);
     $nameValue->getAttribute()->willReturn($name);
     $nameValue->getData()->willReturn('foobar');
     $product->getValues()->willReturn(array($weightValue, $surfaceValue, $nameValue));
     $channel->getConversionUnits()->willReturn(array('weight' => 'GRAM'));
     $converter->setFamily('Weight')->shouldBeCalled();
     $converter->convert('KILOGRAM', 'GRAM', 1)->willReturn(0.001);
     $converter->setFamily('Surface')->shouldNotBeCalled();
     $weightMetric->setData(0.001)->shouldBeCalled();
     $weightMetric->setUnit('GRAM')->shouldBeCalled();
     $this->convert($product, $channel);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:25,代码来源:MetricConverterSpec.php

示例6: let

 function let(AttributeConstraintGuesser $guesser, ProductValueInterface $value, AttributeInterface $color, AttributeOptionInterface $red)
 {
     $value->getAttribute()->willReturn($color);
     $value->getData()->willReturn(new ArrayCollection([$red]));
     $color->getBackendType()->willReturn(AbstractAttributeType::BACKEND_TYPE_OPTIONS);
     $this->beConstructedWith(AbstractAttributeType::BACKEND_TYPE_OPTIONS, 'pim_ajax_entity', $guesser);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:7,代码来源:OptionMultiSelectTypeSpec.php

示例7: prepareValueFormAlias

 /**
  * {@inheritdoc}
  */
 public function prepareValueFormAlias(ProductValueInterface $value)
 {
     if ($value->getAttribute()->isWysiwygEnabled()) {
         return 'pim_wysiwyg';
     }
     return parent::prepareValueFormAlias($value);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:10,代码来源:TextAreaType.php

示例8:

 function it_adds_missing_product_values_from_family_on_new_product($valuesResolver, FamilyInterface $family, ProductInterface $product, AttributeInterface $sku, AttributeInterface $name, AttributeInterface $desc, ProductValueInterface $skuValue)
 {
     $sku->getCode()->willReturn('sku');
     $sku->getAttributeType()->willReturn('pim_catalog_identifier');
     $sku->isLocalizable()->willReturn(false);
     $sku->isScopable()->willReturn(false);
     $name->getCode()->willReturn('name');
     $name->getAttributeType()->willReturn('pim_catalog_text');
     $name->isLocalizable()->willReturn(true);
     $name->isScopable()->willReturn(false);
     $desc->getCode()->willReturn('description');
     $desc->getAttributeType()->willReturn('pim_catalog_text');
     $desc->isLocalizable()->willReturn(true);
     $desc->isScopable()->willReturn(true);
     // get expected attributes
     $product->getAttributes()->willReturn([$sku]);
     $family->getAttributes()->willReturn([$sku, $name, $desc]);
     $product->getFamily()->willReturn($family);
     // get eligible values
     $valuesResolver->resolveEligibleValues(['sku' => $sku, 'name' => $name, 'description' => $desc])->willReturn([['attribute' => 'sku', 'type' => 'pim_catalog_identifier', 'locale' => null, 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => null], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'print'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'print']]);
     // get existing values
     $skuValue->getAttribute()->willReturn($sku);
     $skuValue->getLocale()->willReturn(null);
     $skuValue->getScope()->willReturn(null);
     $product->getValues()->willReturn([$skuValue]);
     // add 6 new values : 4 desc (locales x scopes) + 2 name (locales
     $product->addValue(Argument::any())->shouldBeCalledTimes(6);
     $this->addMissingProductValues($product);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:29,代码来源:ProductBuilderSpec.php

示例9:

 function it_adds_multiple_product_values_children_in_the_same_group(ProductValueInterface $valueOne, AttributeInterface $attributeOne, ProductValueInterface $valueTwo, AttributeInterface $attributeTwo, AttributeGroup $group, FormView $valueFormView, $viewUpdaterRegistry)
 {
     $valueOne->getAttribute()->willReturn($attributeOne);
     $valueOne->isRemovable()->willReturn(true);
     $valueOne->getLocale()->willReturn(null);
     $valueOne->getEntity()->willReturn(null);
     $attributeOne->getGroup()->willReturn($group);
     $attributeOne->getId()->willReturn(42);
     $attributeOne->getCode()->willReturn('name');
     $attributeOne->getLabel()->willReturn('Name');
     $attributeOne->getSortOrder()->willReturn(10);
     $attributeOne->getAttributeType()->willReturn('pim_catalog_text');
     $attributeOne->isLocalizable()->willReturn(false);
     $attributeOne->isScopable()->willReturn(false);
     $valueTwo->getAttribute()->willReturn($attributeTwo);
     $valueTwo->isRemovable()->willReturn(true);
     $valueTwo->getLocale()->willReturn(null);
     $valueTwo->getEntity()->willReturn(null);
     $attributeTwo->getGroup()->willReturn($group);
     $attributeTwo->getId()->willReturn(47);
     $attributeTwo->getCode()->willReturn('description');
     $attributeTwo->getLabel()->willReturn('Description');
     $attributeTwo->getSortOrder()->willReturn(15);
     $attributeTwo->getAttributeType()->willReturn('pim_catalog_text');
     $attributeTwo->isLocalizable()->willReturn(false);
     $attributeTwo->isScopable()->willReturn(false);
     $group->getId()->willReturn(1);
     $group->getCode()->willReturn('general');
     $group->getLabel()->willReturn('General');
     $this->addChildren($valueOne, $valueFormView);
     $this->addChildren($valueTwo, $valueFormView);
     $viewUpdaterRegistry->getUpdaters()->willReturn([]);
     $resultView = [1 => ['label' => 'General', 'attributes' => ['name' => ['id' => 42, 'isRemovable' => true, 'code' => 'name', 'label' => 'Name', 'sortOrder' => 10, 'allowValueCreation' => false, 'locale' => null, 'value' => $valueFormView], 'description' => ['id' => 47, 'isRemovable' => true, 'code' => 'description', 'label' => 'Description', 'sortOrder' => 15, 'allowValueCreation' => false, 'locale' => null, 'value' => $valueFormView]]]];
     $this->getView()->shouldReturn($resultView);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:35,代码来源:ProductFormViewSpec.php

示例10:

 function it_denormalizes_data_into_reference_data($resolver, AttributeInterface $attribute, ReferenceDataInterface $battlecruiser, ReferenceDataRepository $referenceDataRepo, ProductValueInterface $productValue)
 {
     $attribute->getReferenceDataName()->willReturn('starship');
     $productValue->getAttribute()->willReturn($attribute);
     $resolver->resolve('starship')->willReturn($referenceDataRepo);
     $referenceDataRepo->findOneBy(['code' => 'battlecruiser'])->willReturn($battlecruiser);
     $this->denormalize('battlecruiser', 'pim_reference_data_simpleselect', 'csv', ['value' => $productValue])->shouldReturn($battlecruiser);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:8,代码来源:ReferenceDataDenormalizerSpec.php

示例11: it_suports_media_attribute

 public function it_suports_media_attribute(ProductValueInterface $productValue, AttributeInterface $attribute)
 {
     $productValue->getAttribute()->willReturn($attribute);
     $attribute->getBackendType()->willReturn('media');
     $this->supportsValue($productValue)->shouldReturn(true);
     $attribute->getBackendType()->willReturn('other');
     $this->supportsValue($productValue)->shouldReturn(false);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:8,代码来源:MediaCompleteCheckerSpec.php

示例12: getUniqueValueCode

 /**
  * @param ProductValueInterface $productValue
  *
  * @return string
  */
 protected function getUniqueValueCode(ProductValueInterface $productValue)
 {
     $attributeCode = $productValue->getAttribute()->getCode();
     $uniqueValueCode = $attributeCode;
     $uniqueValueCode .= null !== $productValue->getLocale() ? $productValue->getLocale() : '';
     $uniqueValueCode .= null !== $productValue->getScope() ? $productValue->getScope() : '';
     return $uniqueValueCode;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:13,代码来源:UniqueValuesSet.php

示例13:

 function it_denormalizes_a_collection_of_reference_data_values($refDataDenormalizer, AttributeInterface $attribute, ReferenceDataInterface $refData1, ReferenceDataInterface $refData2, ProductValueInterface $productValue)
 {
     $productValue->getAttribute()->willReturn($attribute);
     $context = ['value' => $productValue];
     $refDataDenormalizer->denormalize('battlecruiser', 'pim_reference_data_multiselect', null, $context)->shouldBeCalled()->willReturn($refData1);
     $refDataDenormalizer->denormalize('destroyer', 'pim_reference_data_multiselect', null, $context)->shouldBeCalled()->willReturn($refData2);
     $this->denormalize('battlecruiser,destroyer', 'pim_reference_data_multiselect', null, $context)->shouldHaveCount(2);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:8,代码来源:ReferenceDataCollectionDenormalizerSpec.php

示例14: it_suports_metric_attribute

 public function it_suports_metric_attribute(ProductValueInterface $productValue, AttributeInterface $attribute)
 {
     $productValue->getAttribute()->willReturn($attribute);
     $attribute->getAttributeType()->willReturn('pim_catalog_metric');
     $this->supportsValue($productValue)->shouldReturn(true);
     $attribute->getAttributeType()->willReturn('other');
     $this->supportsValue($productValue)->shouldReturn(false);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:8,代码来源:MetricCompleteCheckerSpec.php

示例15: it_succesfully_checks_complete_attribute

 public function it_succesfully_checks_complete_attribute(ProductValueInterface $value, ChannelInterface $channel, LocaleInterface $locale, ProductValueCompleteCheckerInterface $completenessChecker, AttributeInterface $attribute)
 {
     $value->getAttribute()->willReturn($attribute);
     $value->getData()->willReturn('foo');
     $this->addProductValueChecker($completenessChecker);
     $completenessChecker->supportsValue($value)->willReturn(true);
     $completenessChecker->isComplete($value, $channel, $locale)->willReturn(true);
     $this->isComplete($value, $channel, $locale)->shouldReturn(true);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:9,代码来源:ChainedProductValueCompleteCheckerSpec.php


注:本文中的Pim\Bundle\CatalogBundle\Model\ProductValueInterface::getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。