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


PHP AttributeRepositoryInterface::findOneByIdentifier方法代码示例

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


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

示例1:

 function it_updates_a_family($attrRequiFactory, $channelRepository, FamilyTranslation $translation, FamilyInterface $family, AttributeRepositoryInterface $attributeRepository, AttributeInterface $attribute1, AttributeInterface $attribute2, AttributeInterface $attribute3, AttributeInterface $attribute4, AttributeRequirementInterface $attributeRequirement1, AttributeRequirementInterface $attributeRequirement2, AttributeRequirementInterface $attributeRequirement3, AttributeRequirementInterface $attributeRequirement4, AttributeRequirementInterface $attributeRequirement5, ChannelInterface $channel1, ChannelInterface $channel2, FamilyInterface $family)
 {
     $values = ['code' => 'mycode', 'attributes' => ['sku', 'name', 'description', 'price'], 'attribute_as_label' => 'name', 'requirements' => ['mobile' => ['sku', 'name'], 'print' => ['sku', 'name', 'description']], 'labels' => ['fr_FR' => 'Moniteurs', 'en_US' => 'PC Monitors']];
     $attributeRepository->findOneByIdentifier('sku')->willReturn($attribute1);
     $attributeRepository->findOneByIdentifier('name')->willReturn($attribute2);
     $attributeRepository->findOneByIdentifier('description')->willReturn($attribute3);
     $attributeRepository->findOneByIdentifier('price')->willReturn($attribute4);
     $channelRepository->findOneByIdentifier('mobile')->willReturn($channel1);
     $channelRepository->findOneByIdentifier('print')->willReturn($channel2);
     $attrRequiFactory->createAttributeRequirement($attribute1, $channel1, true)->willReturn($attributeRequirement1);
     $attrRequiFactory->createAttributeRequirement($attribute2, $channel1, true)->willReturn($attributeRequirement2);
     $attrRequiFactory->createAttributeRequirement($attribute1, $channel2, true)->willReturn($attributeRequirement3);
     $attrRequiFactory->createAttributeRequirement($attribute2, $channel2, true)->willReturn($attributeRequirement4);
     $attrRequiFactory->createAttributeRequirement($attribute3, $channel2, true)->willReturn($attributeRequirement5);
     $family->setAttributeRequirements([$attributeRequirement1, $attributeRequirement2, $attributeRequirement3, $attributeRequirement4, $attributeRequirement5])->shouldBeCalled();
     $family->setCode('mycode')->shouldBeCalled();
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->addAttribute($attribute2)->shouldBeCalled();
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->setLocale('en_US')->shouldBeCalled();
     $family->setLocale('fr_FR')->shouldBeCalled();
     $family->getTranslation()->willReturn($translation);
     $translation->setLabel('label en us');
     $translation->setLabel('label fr fr');
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->addAttribute($attribute2)->shouldBeCalled();
     $family->addAttribute($attribute3)->shouldBeCalled();
     $family->addAttribute($attribute4)->shouldBeCalled();
     $family->setAttributeAsLabel($attribute2)->shouldBeCalled();
     $this->update($family, $values, []);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:32,代码来源:FamilyUpdaterSpec.php

示例2: denormalize

 /**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = null, array $context = [])
 {
     $values = new ArrayCollection();
     foreach ($data as $attributeCode => $valuesData) {
         $attribute = $this->attributeRepository->findOneByIdentifier($attributeCode);
         foreach ($valuesData as $valueData) {
             $value = $this->denormalizer->denormalize($valueData, $this->valueClass, 'json', ['attribute' => $attribute] + $context);
             $values->add($value);
         }
     }
     return $values;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:15,代码来源:ProductValuesDenormalizer.php

示例3:

 function it_denormalizes_product_values_from_json($denormalizer, $registry, AttributeRepositoryInterface $attributeRepository, ProductValueInterface $nameValue, ProductValueInterface $colorValue, AttributeInterface $name, AttributeInterface $color)
 {
     $data = ['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']], 'color' => [['locale' => 'en_US', 'scope' => 'ecommerce', 'value' => 'red']]];
     $attributeRepository->findOneByIdentifier('name')->willReturn($name);
     $attributeRepository->findOneByIdentifier('color')->willReturn($color);
     $registry->getRepository('Attribute')->willReturn($attributeRepository);
     $denormalizer->denormalize($data['name'][0], 'ProductValue', 'json', ['attribute' => $name])->shouldBeCalled()->willReturn($nameValue);
     $denormalizer->denormalize($data['color'][0], 'ProductValue', 'json', ['attribute' => $color])->shouldBeCalled()->willReturn($colorValue);
     $values = $this->denormalize($data, 'ProductValue[]', 'json');
     $values->shouldHaveCount(2);
     $values[0]->shouldBe($nameValue);
     $values[1]->shouldBe($colorValue);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:13,代码来源:ProductValuesDenormalizerSpec.php

示例4: setAxis

 /**
  * @param GroupInterface $group
  * @param array          $data
  */
 protected function setAxis(GroupInterface $group, $data)
 {
     if (isset($data['axis']) && !empty($data['axis'])) {
         $axisCodes = explode(',', $data['axis']);
         $attributes = [];
         foreach ($axisCodes as $code) {
             $attribute = $this->attributeRepository->findOneByIdentifier($code);
             if (!$attribute) {
                 throw new \LogicException(sprintf('Attribute with identifier "%s" not found', $code));
             }
             $attributes[] = $attribute;
         }
         $group->setAxisAttributes($attributes);
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:19,代码来源:GroupDenormalizer.php

示例5: process

 /**
  * {@inheritdoc}
  */
 public function process($family)
 {
     $configuration = $this->getJobConfiguration();
     if (!array_key_exists('actions', $configuration)) {
         throw new InvalidArgumentException('Missing configuration for \'actions\'.');
     }
     $actions = $configuration['actions'];
     foreach ($actions as $action) {
         $attribute = $this->attributeRepository->findOneByIdentifier($action['attribute_code']);
         $channel = $this->channelRepository->findOneByIdentifier($action['channel_code']);
         $isRequired = $action['is_required'];
         $family->addAttribute($attribute);
         $family->addAttributeRequirement($this->factory->createAttributeRequirement($attribute, $channel, $isRequired));
     }
     return $family;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:19,代码来源:SetAttributeRequirements.php

示例6: getNonEligibleAttributes

 /**
  * Get non eligible attributes to a product template
  *
  * @param GroupInterface $group
  *
  * @return AttributeInterface[]
  */
 public function getNonEligibleAttributes(GroupInterface $variantGroup)
 {
     $attributes = $variantGroup->getAxisAttributes()->toArray();
     $template = $variantGroup->getProductTemplate();
     if (null !== $template) {
         foreach (array_keys($template->getValuesData()) as $attributeCode) {
             $attributes[] = $this->attributeRepository->findOneByIdentifier($attributeCode);
         }
     }
     $uniqueAttributes = $this->attributeRepository->findBy(['unique' => true]);
     foreach ($uniqueAttributes as $attribute) {
         if (!in_array($attribute, $attributes)) {
             $attributes[] = $attribute;
         }
     }
     return $attributes;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:24,代码来源:VariantGroupAttributesResolver.php

示例7: extractColumnInfo

 /**
  * Extract attribute field name information with attribute code, locale code, scope code
  * and optionally price currency
  *
  * Returned array like:
  * [
  *     "attribute"   => AttributeInterface,
  *     "locale_code" => <locale_code>|null,
  *     "scope_code"  => <scope_code>|null,
  *     "price_currency" => <currency_code> // this key is optional
  * ]
  *
  * Return null if the field name does not match an attribute.
  *
  * @param string $fieldName
  *
  * @return array|null
  */
 public function extractColumnInfo($fieldName)
 {
     if (!isset($this->fieldNameInfoCache[$fieldName]) && !in_array($fieldName, $this->excludedFieldNames)) {
         $explodedFieldName = explode(self::FIELD_SEPARATOR, $fieldName);
         $attributeCode = $explodedFieldName[0];
         $attribute = $this->attributeRepository->findOneByIdentifier($attributeCode);
         if (null !== $attribute) {
             $this->checkFieldNameTokens($attribute, $fieldName, $explodedFieldName);
             $attributeInfo = $this->extractAttributeInfo($attribute, $explodedFieldName);
             $this->checkFieldNameLocaleByChannel($attribute, $fieldName, $attributeInfo);
             $this->fieldNameInfoCache[$fieldName] = $attributeInfo;
         } else {
             $this->excludedFieldNames[] = $fieldName;
         }
     }
     return isset($this->fieldNameInfoCache[$fieldName]) ? $this->fieldNameInfoCache[$fieldName] : null;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:35,代码来源:AttributeColumnInfoExtractor.php

示例8: setAttributeAsLabel

 /**
  * @param FamilyInterface $family
  * @param string          $data
  */
 protected function setAttributeAsLabel(FamilyInterface $family, $data)
 {
     if (null !== ($attribute = $this->attributeRepository->findOneByIdentifier($data))) {
         $family->setAttributeAsLabel($attribute);
     } else {
         throw new \InvalidArgumentException(sprintf('Attribute with "%s" code does not exist', $data));
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:12,代码来源:FamilyUpdater.php

示例9: getAttribute

 /**
  * @param string $code
  *
  * @throws ObjectNotFoundException
  *
  * @return AttributeInterface
  */
 protected function getAttribute($code)
 {
     if (!array_key_exists($code, $this->attributes)) {
         $attribute = $this->attributeRepository->findOneByIdentifier($code);
         if (!$attribute) {
             throw new ObjectNotFoundException(sprintf('Attribute with code "%s" was not found.', $code));
         }
         $this->attributes[$code] = $attribute;
     }
     return $this->attributes[$code];
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:18,代码来源:ProductEditDataFilter.php

示例10: setAxes

 /**
  * @param GroupInterface $variantGroup
  * @param array          $axes
  *
  * @throws \InvalidArgumentException
  */
 protected function setAxes(GroupInterface $variantGroup, array $axes)
 {
     if (null !== $variantGroup->getId()) {
         if (array_diff($this->getOriginalAxes($variantGroup->getAxisAttributes()), array_values($axes))) {
             throw new \InvalidArgumentException('Attributes: This property cannot be changed.');
         }
     }
     foreach ($axes as $axis) {
         $attribute = $this->attributeRepository->findOneByIdentifier($axis);
         if (null !== $attribute) {
             $variantGroup->addAxisAttribute($attribute);
         } else {
             throw new \InvalidArgumentException(sprintf('Attribute "%s" does not exist', $axis));
         }
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:22,代码来源:VariantGroupUpdater.php

示例11:

 function it_throws_exception_when_the_field_name_is_not_consistent_with_the_attribute_property($managerRegistry, AttributeRepositoryInterface $repository, AttributeInterface $attribute)
 {
     // global with extra locale
     $attribute->getCode()->willReturn('sku');
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(false);
     $attribute->getBackendType()->willReturn('text');
     $repository->findOneByIdentifier('sku')->willReturn($attribute);
     $managerRegistry->getRepository(self::ATTRIBUTE_CLASS)->willReturn($repository);
     $this->shouldThrow(new \InvalidArgumentException('The field "sku-fr_FR" is not well-formatted, attribute "sku" expects no locale, no scope, no currency'))->duringExtractAttributeFieldNameInfos('sku-fr_FR');
     // localizable without any locale
     $attribute->getCode()->willReturn('name');
     $attribute->isLocalizable()->willReturn(true);
     $attribute->isScopable()->willReturn(false);
     $attribute->getBackendType()->willReturn('text');
     $repository->findOneByIdentifier('name')->willReturn($attribute);
     $this->shouldThrow(new \InvalidArgumentException('The field "name" is not well-formatted, attribute "name" expects a locale, no scope, no currency'))->duringExtractAttributeFieldNameInfos('name');
     // localizable, scopable and price without any currency
     $attribute->getCode()->willReturn('cost');
     $attribute->isLocalizable()->willReturn(true);
     $attribute->isScopable()->willReturn(true);
     $attribute->getBackendType()->willReturn('prices');
     $repository->findOneByIdentifier('cost')->willReturn($attribute);
     $this->shouldThrow(new \InvalidArgumentException('The field "cost" is not well-formatted, attribute "cost" expects a locale, a scope, an optional currency'))->duringExtractAttributeFieldNameInfos('cost');
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:25,代码来源:FieldNameBuilderSpec.php

示例12: it_should_not_remove_identifier_requirements_when_other_requirements_are_provided

 public function it_should_not_remove_identifier_requirements_when_other_requirements_are_provided($attrRequiFactory, $channelRepository, FamilyInterface $family, AttributeRepositoryInterface $attributeRepository, AttributeInterface $skuAttribute, AttributeInterface $nameAttribute, AttributeInterface $descAttribute, AttributeRequirementInterface $skuMobileRqrmt, AttributeRequirementInterface $skuPrintRqrmt, AttributeRequirementInterface $namePrintRqrmt, AttributeRequirementInterface $descPrintRqrmt, ChannelInterface $mobileChannel, ChannelInterface $printChannel)
 {
     $values = ['code' => 'mycode', 'requirements' => ['print' => ['name', 'description']]];
     $family->getAttributeRequirements()->willReturn([$skuMobileRqrmt, $skuPrintRqrmt]);
     $skuMobileRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuPrintRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuMobileRqrmt->getChannelCode()->willReturn('mobile');
     $skuPrintRqrmt->getChannelCode()->willReturn('print');
     $skuAttribute->getAttributeType()->willReturn(AttributeTypes::IDENTIFIER);
     $channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
     $attributeRepository->findOneByIdentifier('name')->willReturn($nameAttribute);
     $attributeRepository->findOneByIdentifier('description')->willReturn($descAttribute);
     $attrRequiFactory->createAttributeRequirement($nameAttribute, $printChannel, true)->willReturn($namePrintRqrmt);
     $attrRequiFactory->createAttributeRequirement($descAttribute, $printChannel, true)->willReturn($descPrintRqrmt);
     $namePrintRqrmt->getAttribute()->willReturn($nameAttribute);
     $descPrintRqrmt->getAttribute()->willReturn($descAttribute);
     $channelRepository->getChannelCodes()->willReturn(['mobile', 'print']);
     $channelRepository->findOneByIdentifier('mobile')->willReturn($mobileChannel);
     $channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
     $attributeRepository->getIdentifier()->willReturn($skuAttribute);
     $family->setCode('mycode')->shouldBeCalled();
     $family->setAttributeRequirements([$skuMobileRqrmt, $skuPrintRqrmt, $namePrintRqrmt, $descPrintRqrmt])->shouldBeCalled();
     $this->update($family, $values, []);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:24,代码来源:FamilyUpdaterSpec.php

示例13: findAttribute

 /**
  * @param string $code
  *
  * @return AttributeInterface|null
  */
 protected function findAttribute($code)
 {
     $attribute = $this->attributeRepository->findOneByIdentifier($code);
     return $attribute;
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:10,代码来源:AttributeOptionUpdater.php


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