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


PHP ProductValueInterface::getMetric方法代码示例

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


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

示例1: isComplete

 /**
  * {@inheritdoc}
  */
 public function isComplete(ProductValueInterface $productValue, ChannelInterface $channel = null, LocaleInterface $locale = null)
 {
     $metric = $productValue->getMetric();
     if (!$metric || null === $metric->getData()) {
         return false;
     }
     return true;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:11,代码来源:MetricCompleteChecker.php

示例2:

 function it_validates_product_value_with_metric_data($accessor, $context, ValidMetric $constraint, ProductValueInterface $value, MetricInterface $metric)
 {
     $value->getMetric()->willReturn($metric);
     $metric->getUnit()->willReturn('cm');
     $metric->getData()->willReturn(12);
     $accessor->getValue($metric, 'family')->shouldBeCalled()->willReturn('Weight');
     $accessor->getValue($metric, 'unit')->shouldBeCalled()->willReturn('kg');
     $context->addViolationAt(Argument::any(), Argument::any())->shouldNotBeCalled();
     $this->validate($value, $constraint)->shouldReturn(null);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:10,代码来源:ValidMetricValidatorSpec.php

示例3: addFromManyFields

 /**
  * The metric is built by many ordered calls, one for the data column, one for the unit column
  *
  * @param ProductValueInterface $value
  * @param string                $dataOrUnit
  *
  * @return \Pim\Bundle\CatalogBundle\Model\MetricInterface
  */
 protected function addFromManyFields(ProductValueInterface $value, $dataOrUnit)
 {
     // TODO come from original implementation, really FRAGIL because depends on many ordered calls
     if (null === ($metric = $value->getMetric())) {
         $metric = $this->factory->createMetric($value->getAttribute()->getMetricFamily());
         $metric->setData($dataOrUnit);
     } else {
         $metric->setUnit($dataOrUnit);
     }
     return $metric;
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:19,代码来源:MetricDenormalizer.php

示例4:

 function it_denormalizes_a_new_metric_from_a_single_field_and_set_data_and_unit(ProductValueInterface $metricValue, MetricInterface $metric, AttributeInterface $weight, $metricFactory)
 {
     $context = ['value' => $metricValue];
     $metricValue->getMetric()->willReturn(null);
     $metricValue->getAttribute()->willReturn($weight);
     $weight->getMetricFamily()->willReturn('Weight');
     $metricFactory->createMetric('Weight')->willReturn($metric);
     $metric->setData('100')->shouldBeCalled();
     $metric->setUnit('KILOGRAM')->shouldBeCalled();
     $this->denormalize('100 KILOGRAM', 'className', null, $context)->shouldReturn($metric);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:11,代码来源:MetricDenormalizerSpec.php

示例5: it_succesfully_checks_complete_metric

 public function it_succesfully_checks_complete_metric(ProductValueInterface $value, ChannelInterface $channel, LocaleInterface $locale, MetricInterface $metric)
 {
     $value->getMetric()->willReturn(null);
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
     $value->getMetric()->willReturn([]);
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
     $metric->getData()->willReturn(null);
     $value->getMetric()->willReturn($metric);
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
     $metric->getData()->willReturn('foobar');
     $value->getMetric()->willReturn($metric);
     $this->isComplete($value, $channel, $locale)->shouldReturn(true);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:13,代码来源:MetricCompleteCheckerSpec.php

示例6: 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();
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:29,代码来源:ValidMetricValidator.php

示例7: validateMetric

 /**
  * Check if the metric value is not empty
  *
  * @param ProductValueInterface $value
  * @param Constraint            $constraint
  */
 protected function validateMetric(ProductValueInterface $value, Constraint $constraint)
 {
     $metric = $value->getMetric();
     if (!$metric || $metric->getData() === null) {
         $this->context->addViolation($constraint->messageComplete);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:ProductValueCompleteValidator.php

示例8: Metric

 function it_returns_null_when_unknown_backendtype($context, ProductValueComplete $constraint, ProductValueInterface $productValue, AttributeInterface $attribute)
 {
     $constraint->getChannel()->willReturn($this->getChannel());
     $metric = new Metric();
     $productValue->getMetric()->willReturn($metric);
     $productValue->getData()->willReturn('data');
     $attribute->getBackendType()->willReturn('unknown_metric');
     $productValue->getAttribute()->willReturn($attribute);
     $context->buildViolation(Argument::any())->shouldNotBeCalled();
     $this->validate($productValue, $constraint);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:11,代码来源:ProductValueCompleteValidatorSpec.php

示例9:

 function it_returns_a_metric_if_the_data_is_empty(ProductValueInterface $metricValue, MetricInterface $metric)
 {
     $metricValue->getMetric()->willReturn($metric);
     $this->denormalize('', 'className', null, ['value' => $metricValue])->shouldReturn($metric);
     $this->denormalize(null, 'className', null, ['value' => $metricValue])->shouldReturn($metric);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:6,代码来源:MetricDenormalizerSpec.php

示例10: setProductMetric

 /**
  * @param ProductValueInterface $productValue
  * @param ProductValueInterface $value
  */
 protected function setProductMetric(ProductValueInterface $productValue, ProductValueInterface $value)
 {
     if (null === ($metric = $productValue->getMetric())) {
         $metric = $this->metricFactory->createMetric($value->getAttribute()->getMetricFamily());
         $productValue->setMetric($metric);
     }
     $metric->setUnit($value->getMetric()->getUnit());
     $metric->setData($value->getMetric()->getData());
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:13,代码来源:EditCommonAttributes.php


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