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


PHP Model\ProductValueInterface类代码示例

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


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

示例1: 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

示例2: 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

示例3: prepareValueFormData

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

示例4:

 function it_adds_violation_with_non_unique_value(ProductManager $productManager, ProductValueInterface $value, ExecutionContextInterface $context, UniqueValue $constraint)
 {
     $value->getData()->willReturn('a content');
     $productManager->valueExists($value)->willReturn(true);
     $context->addViolation($constraint->message)->shouldBeCalled();
     $this->validate("my_value", $constraint)->shouldReturn(null);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:7,代码来源:UniqueValueValidatorSpec.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: foreach

 function it_copies_simple_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValueInterface $fromProductValue, ProductValueInterface $toProductValue, AttributeOptionInterface $attributeOption)
 {
     $fromLocale = 'fr_FR';
     $toLocale = 'fr_FR';
     $toScope = 'mobile';
     $fromScope = 'mobile';
     $fromAttribute->getCode()->willReturn('fromAttributeCode');
     $toAttribute->getCode()->willReturn('toAttributeCode');
     $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled();
     $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled();
     $fromProductValue->getData()->willReturn($attributeOption);
     $toProductValue->setOption($attributeOption)->shouldBeCalledTimes(3);
     $product1->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
     $product1->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
     $product2->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn(null);
     $product2->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
     $product3->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
     $product3->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null);
     $product4->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
     $product4->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
     $builder->addProductValue($product3, $toAttribute, $toLocale, $toScope)->shouldBeCalledTimes(1)->willReturn($toProductValue);
     $products = [$product1, $product2, $product3, $product4];
     foreach ($products as $product) {
         $this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]);
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:26,代码来源:SimpleSelectAttributeCopierSpec.php

示例7:

 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

示例8: 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

示例9:

 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

示例10: supportsValue

 /**
  * {@inheritdoc}
  */
 public function supportsValue(ProductValueInterface $productValue)
 {
     $data = $productValue->getData();
     if (null === $data || '' === $data || [] === $data || $data instanceof \Countable && 0 === count($data)) {
         return true;
     }
     return false;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:11,代码来源:EmptyChecker.php

示例11:

 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

示例12: validate

 /**
  * Validate currency of a price
  *
  * @param AttributeInterface|MetricInterface|ProductValueInterface $object
  * @param Constraint                                               $constraint
  */
 public function validate($object, Constraint $constraint)
 {
     if ($object instanceof ProductPriceInterface) {
         if (!in_array($object->getCurrency(), $this->getCurrencyCodes())) {
             $this->context->addViolationAt('currency', $constraint->unitMessage);
         }
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:14,代码来源:CurrencyValidator.php

示例13:

 function it_doesnt_support_multi_targets_constraint($guesser, $factory, ClassMetadata $metadata, ProductValueInterface $value, AttributeInterface $attribute, Constraint $multiTargets, Constraint $validNumber)
 {
     $factory->createMetadata(Argument::any())->willReturn($metadata);
     $value->getAttribute()->willReturn($attribute);
     $attribute->getBackendType()->willReturn('varchar');
     $guesser->guessConstraints($attribute)->willReturn([$multiTargets]);
     $multiTargets->getTargets()->willReturn([Constraint::PROPERTY_CONSTRAINT, Constraint::CLASS_CONSTRAINT]);
     $this->shouldThrow(new \LogicException('No support provided for constraint on many targets'))->duringGetMetadataFor($value);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:9,代码来源:ProductValueMetadataFactorySpec.php

示例14: markAttributeAsUpdatedByVariant

 /**
  * Mark attribute as variant
  *
  * @param FormView              $view
  * @param ProductValueInterface $value
  */
 protected function markAttributeAsUpdatedByVariant(FormView $view, ProductValueInterface $value)
 {
     $view->vars['from_variant'] = $value->getEntity()->getVariantGroup();
     $view->vars['disabled'] = true;
     $view->vars['read_only'] = true;
     foreach ($view as $child) {
         $this->markAttributeAsUpdatedByVariant($child, $value);
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:15,代码来源:VariantViewUpdater.php

示例15:

 function it_doesnt_remove_value_when_the_attribute_is_not_locale_specific(FormEvent $event, FormInterface $form, FormInterface $field, FormInterface $rootForm, ProductValueInterface $nameValue, AttributeInterface $nameAttribute)
 {
     $event->getForm()->willReturn($form);
     $event->getData()->willReturn(['name' => $nameValue]);
     $nameValue->getAttribute()->willReturn($nameAttribute);
     $nameAttribute->isLocaleSpecific()->willReturn(false);
     $form->remove('name')->shouldNotBeCalled();
     $this->preSetData($event);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:9,代码来源:FilterLocaleSpecificValueSubscriberSpec.php


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