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


PHP ProductValueInterface::getLocale方法代码示例

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


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

示例1: use

 function it_allows_to_get_errors_if_the_copy_went_wrong($mediaFetcher, $filesystemProvider, $fileExporterPath, FileInfoInterface $fileInfo, FileInfoInterface $fileInfo2, ArrayCollection $productValuesCollection, \ArrayIterator $valuesIterator, ProductValueInterface $productValue, ProductValueInterface $productValue2, AttributeInterface $attribute, FilesystemInterface $filesystem)
 {
     $fileInfo->getStorage()->willReturn('storageAlias');
     $fileInfo->getKey()->willReturn('a/b/c/d/product.jpg');
     $fileInfo->getOriginalFilename()->willReturn('my product.jpg');
     $fileInfo2->getStorage()->willReturn('storageAlias');
     $fileInfo2->getKey()->willReturn('wrong-path.jpg');
     $fileInfo2->getOriginalFilename()->willReturn('my-second-media.jpg');
     $productValue->getAttribute()->willReturn($attribute);
     $productValue->getMedia()->willReturn($fileInfo);
     $productValue->getLocale()->willReturn('en_US');
     $productValue->getScope()->willReturn(null);
     $productValue2->getAttribute()->willReturn($attribute);
     $productValue2->getMedia()->willReturn($fileInfo2);
     $productValue2->getLocale()->willReturn('fr_FR');
     $productValue2->getScope()->willReturn('ecommerce');
     $attribute->getAttributeType()->willReturn('pim_catalog_image');
     $attribute->getCode()->willReturn('my_picture');
     $productValuesCollection->getIterator()->willReturn($valuesIterator);
     $valuesIterator->rewind()->shouldBeCalled();
     $valuesCount = 2;
     $valuesIterator->valid()->will(function () use(&$valuesCount) {
         return $valuesCount-- > 0;
     });
     $valuesIterator->next()->shouldBeCalled();
     $valuesIterator->current()->will(new ReturnPromise([$productValue, $productValue2]));
     $filesystemProvider->getFilesystem('storageAlias')->willReturn($filesystem);
     $mediaFetcher->fetch($filesystem, 'a/b/c/d/product.jpg', ['filePath' => $this->directory . 'files/the_sku/my_picture/en_US/', 'filename' => 'my product.jpg'])->willThrow(new FileTransferException());
     $fileExporterPath->generate(['locale' => 'en_US', 'scope' => null], ['identifier' => 'the_sku', 'code' => 'my_picture'])->willReturn('files/the_sku/my_picture/en_US/');
     $mediaFetcher->fetch($filesystem, 'wrong-path.jpg', ['filePath' => $this->directory . 'files/the_sku/my_picture/fr_FR/ecommerce/', 'filename' => 'my-second-media.jpg'])->willThrow(new \LogicException('Something went wrong.'));
     $fileExporterPath->generate(['locale' => 'fr_FR', 'scope' => 'ecommerce'], ['identifier' => 'the_sku', 'code' => 'my_picture'])->willReturn('files/the_sku/my_picture/fr_FR/ecommerce/');
     $this->fetchAll($productValuesCollection, $this->directory, 'the_sku');
     $this->getErrors()->shouldBeEqualTo([['message' => 'The media has not been found or is not currently available', 'media' => ['from' => 'a/b/c/d/product.jpg', 'to' => ['filePath' => $this->directory . 'files/the_sku/my_picture/en_US/', 'filename' => 'my product.jpg'], 'storage' => 'storageAlias']], ['message' => 'The media has not been copied. Something went wrong.', 'media' => ['from' => 'wrong-path.jpg', 'to' => ['filePath' => $this->directory . 'files/the_sku/my_picture/fr_FR/ecommerce/', 'filename' => 'my-second-media.jpg'], 'storage' => 'storageAlias']]]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:34,代码来源:BulkMediaFetcherSpec.php

示例2:

 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], null, null)->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:a2xchip,项目名称:pim-community-dev,代码行数:29,代码来源:ProductBuilderSpec.php

示例3:

 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:abdeldayem,项目名称:pim-community-dev,代码行数:35,代码来源:ProductFormViewSpec.php

示例4: it_does_not_filter_a_product_value_if_it_is_in_locales_options

 public function it_does_not_filter_a_product_value_if_it_is_in_locales_options(ProductValueInterface $price, AttributeInterface $priceAttribute)
 {
     $price->getAttribute()->willReturn($priceAttribute);
     $priceAttribute->isLocalizable()->willReturn(false);
     $price->getLocale()->willReturn('fr_FR');
     $this->filterObject($price, 'pim:product_value:view', ['locales' => ['en_US', 'fr_FR']])->shouldReturn(false);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:ProductValueLocaleFilterSpec.php

示例5:

 function it_normalizes_constraint_violation(ConstraintViolationInterface $violation, ProductInterface $product, ProductValueInterface $productValue, AttributeInterface $attribute)
 {
     $product->getValues()->willReturn(['price' => $productValue]);
     $productValue->getLocale()->willReturn(null);
     $productValue->getScope()->willReturn(null);
     $productValue->getAttribute()->willReturn($attribute);
     $attribute->getCode()->willReturn('price');
     $violation->getPropertyPath()->willReturn('values[price].float');
     $violation->getMessage()->willReturn('The price should be above 10.');
     $this->normalize($violation, 'internal_api', ['product' => $product])->shouldReturn(['attribute' => 'price', 'locale' => null, 'scope' => null, 'message' => 'The price should be above 10.']);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:11,代码来源:ProductViolationNormalizerSpec.php

示例6:

 function it_adds_violations_if_value_is_localizable_and_its_locale_does_not_exist($context, $localeRepository, ProductValueInterface $value, AttributeInterface $localizableAttribute, LocalizableValue $constraint, ConstraintViolationBuilderInterface $violation)
 {
     $value->getAttribute()->willReturn($localizableAttribute);
     $localizableAttribute->isLocalizable()->willReturn(true);
     $value->getLocale()->willReturn('inexistingLocale');
     $localizableAttribute->getCode()->willReturn('attributeCode');
     $localeRepository->findOneByIdentifier('inexistingLocale')->willReturn(null);
     $violationData = ['%attribute%' => 'attributeCode', '%locale%' => 'inexistingLocale'];
     $context->buildViolation($constraint->inexistingLocaleMessage, $violationData)->shouldBeCalled()->willReturn($violation);
     $this->validate($value, $constraint);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:LocalizableValueValidatorSpec.php

示例7:

 function it_normalizes_date($serializer, ProductValueInterface $productValue, AttributeInterface $attribute)
 {
     $productValue->getData()->willReturn('2000-10-28');
     $productValue->getScope()->willReturn(null);
     $productValue->getLocale()->willReturn(null);
     $attribute->getAttributeType()->willReturn(AttributeTypes::DATE);
     $attribute->isDecimalsAllowed()->willReturn(false);
     $productValue->getAttribute()->willReturn($attribute);
     $serializer->normalize('2000-10-28', 'json', ['decimals_allowed' => false])->willReturn('2000-10-28');
     $this->normalize($productValue, 'json', ['decimals_allowed' => false])->shouldReturn(['locale' => null, 'scope' => null, 'data' => '2000-10-28']);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:ProductValueNormalizerSpec.php

示例8:

 function it_generates_the_path_when_the_value_is_localisable_and_scopable(ProductValueInterface $value, FileInfoInterface $fileInfo, AttributeInterface $attribute)
 {
     $value->getMedia()->willReturn($fileInfo);
     $value->getLocale()->willReturn('fr_FR');
     $value->getScope()->willReturn('ecommerce');
     $value->getAttribute()->willReturn($attribute);
     $fileInfo->getOriginalFilename()->willReturn('file.jpg');
     $attribute->getCode()->willReturn('picture');
     $attribute->isLocalizable()->willReturn(true);
     $attribute->isScopable()->willReturn(true);
     $this->generate($value, ['identifier' => 'sku001'])->shouldReturn('files/sku001/picture/fr_FR/ecommerce/file.jpg');
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:12,代码来源:MediaExporterPathGeneratorSpec.php

示例9:

 function it_normalizes_a_product_value_into_mongodb_document($mongoFactory, $serializer, ProductValueInterface $value, AttributeInterface $attribute, \MongoDBRef $mongoDBRef, \MongoId $mongoId)
 {
     $context = ['_id' => $mongoId, 'collection_name' => 'product'];
     $mongoFactory->createMongoId()->willReturn($mongoId);
     $mongoFactory->createMongoDBRef('product', $mongoId)->willReturn($mongoDBRef);
     $attribute->getId()->willReturn(123);
     $attribute->getBackendType()->willReturn('text');
     $value->getAttribute()->willReturn($attribute);
     $value->getData()->willReturn('my description');
     $value->getLocale()->willReturn(null);
     $value->getScope()->willReturn(null);
     $this->normalize($value, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'attribute' => 123, 'entity' => $mongoDBRef, 'text' => 'my description']);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:ProductValueNormalizerSpec.php

示例10: hasValue

 /**
  * {@inheritdoc}
  */
 public function hasValue(ProductValueInterface $value)
 {
     $attributeCode = $value->getAttribute()->getCode();
     if (!isset($this->valuesData[$attributeCode])) {
         return false;
     }
     $valuesData = $this->valuesData[$attributeCode];
     foreach ($valuesData as $valueData) {
         if ($valueData['locale'] === $value->getLocale() && $valueData['scope'] === $value->getScope()) {
             return true;
         }
     }
     return false;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:17,代码来源:ProductTemplate.php

示例11:

 function it_does_not_add_value_if_already_present(ProductValueInterface $notPresent, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $present, ProductInterface $anotherProduct)
 {
     $notPresent->getProduct()->willReturn($product);
     $notPresent->getData()->willReturn('new-data');
     $notPresent->getAttribute()->willReturn($attribute);
     $notPresent->getLocale()->willReturn(null);
     $notPresent->getScope()->willReturn(null);
     $attribute->getCode()->willReturn('sku');
     $this->addValue($notPresent)->shouldReturn(true);
     $present->getProduct()->willReturn($anotherProduct);
     $present->getData()->willReturn('new-data');
     $present->getAttribute()->willReturn($attribute);
     $present->getLocale()->willReturn(null);
     $present->getScope()->willReturn(null);
     $attribute->getCode()->willReturn('sku');
     $this->addValue($present)->shouldReturn(false);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:17,代码来源:UniqueValuesSetSpec.php

示例12: filterLocaleSpecific

 /**
  * Check if the attribute is locale specific and check if the given local exist in available locales
  *
  * @param ProductValueInterface $value
  *
  * @return bool
  */
 protected function filterLocaleSpecific(ProductValueInterface $value)
 {
     /** @var AttributeInterface $attribute */
     $attribute = $value->getAttribute();
     if ($attribute->isLocaleSpecific()) {
         $currentLocale = $value->getLocale();
         $availableLocales = $attribute->getLocaleSpecificCodes();
         if (!in_array($currentLocale, $availableLocales)) {
             return true;
         }
     }
     return false;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:20,代码来源:ProductValueNormalizer.php

示例13: getFieldValue

 /**
  * Normalize the field name for values
  *
  * @param ProductValueInterface $value
  *
  * @return string
  */
 protected function getFieldValue($value)
 {
     $suffix = '';
     if ($value->getAttribute()->isLocalizable()) {
         $suffix = sprintf('-%s', $value->getLocale());
     }
     if ($value->getAttribute()->isScopable()) {
         $suffix .= sprintf('-%s', $value->getScope());
     }
     return $value->getAttribute()->getCode() . $suffix;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:18,代码来源:ProductValueNormalizer.php

示例14: getNormalizedValueFieldFromValue

 /**
  * Normalize the field name for value
  *
  * @param ProductValueInterface $value
  *
  * @return string
  */
 public static function getNormalizedValueFieldFromValue(ProductValueInterface $value)
 {
     return self::getNormalizedValueField($value->getAttribute(), $value->getLocale(), $value->getScope());
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:ProductQueryUtility.php

示例15: 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:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:UniqueValuesSet.php


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