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


PHP Repository\AttributeRepositoryInterface类代码示例

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


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

 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

示例3: resolveAttributeColumns

 /**
  * @return array
  */
 public function resolveAttributeColumns()
 {
     if (empty($this->attributesFields)) {
         $attributes = $this->attributeRepository->findAll();
         $currencyCodes = $this->currencyRepository->getActivatedCurrencyCodes();
         $values = $this->valuesResolver->resolveEligibleValues($attributes);
         foreach ($values as $value) {
             if (null !== $value['locale'] && null !== $value['scope']) {
                 $field = sprintf('%s-%s-%s', $value['attribute'], $value['locale'], $value['scope']);
             } elseif (null !== $value['locale']) {
                 $field = sprintf('%s-%s', $value['attribute'], $value['locale']);
             } elseif (null !== $value['scope']) {
                 $field = sprintf('%s-%s', $value['attribute'], $value['scope']);
             } else {
                 $field = $value['attribute'];
             }
             if (AttributeTypes::PRICE_COLLECTION === $value['type']) {
                 $this->attributesFields[] = $field;
                 foreach ($currencyCodes as $currencyCode) {
                     $currencyField = sprintf('%s-%s', $field, $currencyCode);
                     $this->attributesFields[] = $currencyField;
                 }
             } elseif (AttributeTypes::METRIC === $value['type']) {
                 $this->attributesFields[] = $field;
                 $metricField = sprintf('%s-%s', $field, 'unit');
                 $this->attributesFields[] = $metricField;
             } else {
                 $this->attributesFields[] = $field;
             }
         }
     }
     return $this->attributesFields;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:36,代码来源:AttributeColumnsResolver.php

示例4: getMediaAttributes

 /**
  * Get the media attributes
  *
  * @return string[]
  */
 public function getMediaAttributes()
 {
     if (null === $this->mediaAttributes) {
         $this->mediaAttributes = $this->attributeRepository->findMediaAttributeCodes();
     }
     return $this->mediaAttributes;
 }
开发者ID:qrz-io,项目名称:pim-community-dev,代码行数:12,代码来源:CsvProductReader.php

示例5: getFilter

 /**
  * {@inheritdoc}
  */
 public function getFilter($code)
 {
     $attribute = $this->attributeRepository->findOneBy(['code' => FieldFilterHelper::getCode($code)]);
     if (null !== $attribute) {
         return $this->getAttributeFilter($attribute);
     }
     return $this->getFieldFilter($code);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:11,代码来源:FilterRegistry.php

示例6: getAttribute

 /**
  * Fetch the attribute by its code
  *
  * @param string $code
  *
  * @throws \LogicException
  *
  * @return AttributeInterface
  */
 protected function getAttribute($code)
 {
     $attribute = $this->attributeRepository->findOneBy(['code' => $code]);
     if ($attribute === null) {
         throw new \LogicException(sprintf('Unknown attribute "%s".', $code));
     }
     return $attribute;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:17,代码来源:ProductUpdater.php

示例7: validate

 /**
  * Don't allow creating an identifier attribute if one already exists
  *
  * @param AttributeInterface $attribute
  * @param Constraint         $constraint
  */
 public function validate($attribute, Constraint $constraint)
 {
     if (AttributeTypes::IDENTIFIER === $attribute->getAttributeType()) {
         $identifier = $this->attributeRepository->getIdentifier();
         if ($identifier && $identifier->getId() !== $attribute->getId()) {
             $this->context->buildViolation($constraint->message)->atPath('attributeType')->addViolation();
         }
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:15,代码来源:SingleIdentifierAttributeValidator.php

示例8: validate

 /**
  * Don't allow creating an identifier attribute if one already exists
  *
  * @param AttributeInterface $attribute
  * @param Constraint         $constraint
  */
 public function validate($attribute, Constraint $constraint)
 {
     if ($attribute->getAttributeType() === 'pim_catalog_identifier') {
         $identifier = $this->attributeRepository->getIdentifier();
         if ($identifier && $identifier->getId() !== $attribute->getId()) {
             $this->context->addViolationAt('attributeType', $constraint->message);
         }
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:15,代码来源:SingleIdentifierAttributeValidator.php

示例9: findCommonAttributes

 /**
  * Find common attributes
  * Common attributes are:
  *   - not unique (and not identifier)
  *   - without value AND link to family
  *   - with value
  *
  * @param ProductInterface[] $products
  *
  * @return AttributeInterface[]
  */
 public function findCommonAttributes(array $products)
 {
     $productIds = [];
     foreach ($products as $product) {
         $productIds[] = $product->getId();
     }
     $attributeIds = $this->massActionRepository->findCommonAttributeIds($productIds);
     return $this->attributeRepository->findWithGroups(array_unique($attributeIds), ['conditions' => ['unique' => 0]]);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:20,代码来源:ProductMassActionManager.php

示例10: getAttribute

 /**
  * Load the attribute for this filter
  * Required to prepare choice url params and filter configuration
  *
  * @throws \LogicException
  */
 protected function getAttribute()
 {
     $fieldName = $this->get(ProductFilterUtility::DATA_NAME_KEY);
     $attribute = $this->attributeRepository->findOneByCode($fieldName);
     if (!$attribute) {
         throw new \LogicException(sprintf('There is no attribute with code %s.', $fieldName));
     }
     return $attribute;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:15,代码来源:ChoiceFilter.php

示例11: getFieldsList

 /**
  * Get fields for products
  *
  * @param array $productIds
  *
  * @return array
  */
 public function getFieldsList($productIds)
 {
     $this->prepareAvailableAttributeIds($productIds);
     $attributes = $this->getAttributeIds();
     if (empty($attributes)) {
         return [];
     }
     $attributes = $this->attributeRepository->findBy(['id' => $this->getAttributeIds()]);
     return $this->prepareFieldsList($attributes);
 }
开发者ID:VinceBLOT,项目名称:pim-community-dev,代码行数:17,代码来源:ProductFieldsBuilder.php

示例12: initialize

 /**
  * {@inheritdoc}
  */
 public function initialize()
 {
     $this->channels = $this->channelRepository->findAll();
     foreach ($this->attributeRepository->getNonIdentifierAttributes() as $attribute) {
         $this->attributes[(string) $attribute->getGroup()][] = $attribute;
         foreach ($this->channels as $channel) {
             $this->addAttributeRequirement($this->factory->createAttributeRequirement($attribute, $channel, false));
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:SetAttributeRequirements.php

示例13: createFamily

 /**
  * @return FamilyInterface
  */
 public function createFamily()
 {
     $family = new $this->familyClass();
     $identifier = $this->attributeRepository->getIdentifier();
     $family->addAttribute($identifier);
     $family->setAttributeAsLabel($identifier);
     foreach ($this->getChannels() as $channel) {
         $requirement = $this->factory->createAttributeRequirement($identifier, $channel, true);
         $family->addAttributeRequirement($requirement);
     }
     return $family;
 }
开发者ID:qrz-io,项目名称:pim-community-dev,代码行数:15,代码来源:FamilyFactory.php

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

示例15: indexAction

 /**
  * Get the attribute collection
  *
  * @return JsonResponse
  */
 public function indexAction(Request $request)
 {
     $criteria = [];
     if ($request->query->has('identifiers')) {
         $criteria['code'] = explode(',', $request->query->get('identifiers'));
     }
     if ($request->query->has('types')) {
         $criteria['attributeType'] = explode(',', $request->query->get('types'));
     }
     $attributes = $this->attributeRepository->findBy($criteria);
     $filteredAttributes = $this->collectionFilter->filterCollection($attributes, 'pim.internal_api.attribute.view');
     $normalizedAttributes = $this->normalizer->normalize($filteredAttributes, 'internal_api');
     return new JsonResponse($normalizedAttributes);
 }
开发者ID:VinceBLOT,项目名称:pim-community-dev,代码行数:19,代码来源:AttributeController.php


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