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


PHP AttributeRepositoryInterface::findOneBy方法代码示例

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


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

示例1: getFilter

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

示例2: convertDefaultToLocalizedValue

 /**
  * {@inheritdoc}
  */
 public function convertDefaultToLocalizedValue($code, $data, $options = [])
 {
     $attribute = $this->attributeRepository->findOneBy(['code' => $code]);
     if (null === $attribute) {
         return $data;
     }
     $attributeType = $attribute->getAttributeType();
     if (null === $attributeType) {
         return $data;
     }
     $localizer = $this->localizerRegistry->getLocalizer($attributeType);
     if (null === $localizer) {
         return $data;
     }
     return $localizer->localize($data, $options);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:19,代码来源:LocalizedAttributeConverter.php

示例3: ConstraintViolation

 function it_sets_invalid_values_to_attributes($validator, $propertySetter, AttributeInterface $attribute, AttributeRepositoryInterface $attributeRepository, ProductInterface $product, ConstraintViolationListInterface $violations, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration)
 {
     $stepExecution->getJobExecution()->willReturn($jobExecution);
     $jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration);
     $jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => [['field' => 'categories', 'value' => ['office', 'bedroom'], 'options' => []]]]));
     $validator->validate($product)->willReturn($violations);
     $violation = new ConstraintViolation('error2', 'spec', [], '', '', $product);
     $violations = new ConstraintViolationList([$violation, $violation]);
     $validator->validate($product)->willReturn($violations);
     $attributeRepository->findOneBy(['code' => 'categories'])->willReturn($attribute);
     $product->isAttributeEditable($attribute)->willReturn(true);
     $propertySetter->setData($product, 'categories', ['office', 'bedroom'], [])->shouldBeCalled();
     $this->setStepExecution($stepExecution);
     $stepExecution->addWarning(Argument::cetera())->shouldBeCalled();
     $stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled();
     $this->process($product);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:EditCommonAttributesProcessorSpec.php

示例4: addslashes

 function it_sets_values_to_attributes($validator, $productUpdater, AttributeInterface $attribute, AttributeRepositoryInterface $attributeRepository, ProductInterface $product, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration, LocalizerInterface $localizer)
 {
     $this->setStepExecution($stepExecution);
     $stepExecution->getJobExecution()->willReturn($jobExecution);
     $jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration);
     $values = ['number' => [['scope' => null, 'locale' => null, 'data' => '2.5']]];
     $normalizedValues = addslashes(json_encode($values));
     $jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => ['normalized_values' => $normalizedValues, 'ui_locale' => 'fr_FR', 'attribute_locale' => 'en_US', 'attribute_channel' => null]]));
     $violations = new ConstraintViolationList([]);
     $validator->validate($product)->willReturn($violations);
     $attribute->getAttributeType()->willReturn('number');
     $attributeRepository->findOneBy(['code' => 'number'])->willReturn($attribute);
     $attributeRepository->findOneByIdentifier('number')->willReturn($attribute);
     $product->isAttributeEditable($attribute)->willReturn(true);
     $productUpdater->update($product, $values)->shouldBeCalled();
     $this->process($product);
 }
开发者ID:SamirBoulil,项目名称:pim-community-dev,代码行数:17,代码来源:EditCommonAttributesProcessorSpec.php

示例5: addSorter

 /**
  * {@inheritdoc}
  */
 public function addSorter($field, $direction, array $context = [])
 {
     $attribute = $this->attributeRepository->findOneBy(['code' => $field]);
     if (null !== $attribute) {
         $sorter = $this->sorterRegistry->getAttributeSorter($attribute);
     } else {
         $sorter = $this->sorterRegistry->getFieldSorter($field);
     }
     if (null === $sorter) {
         throw new \LogicException(sprintf('Sorter on field "%s" is not supported', $field));
     }
     $context = $this->getFinalContext($context);
     if (null !== $attribute) {
         $this->addAttributeSorter($sorter, $attribute, $direction, $context);
     } else {
         $this->addFieldSorter($sorter, $field, $direction, $context);
     }
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:22,代码来源:ProductQueryBuilder.php

示例6: updateProduct

 /**
  * Set data from $actions to the given $product
  *
  * Actions should looks like that
  *
  * $actions =
  * [
  *     [
  *          'field'   => 'group',
  *          'value'   => 'summer_clothes',
  *          'options' => null
  *      ],
  *      [
  *          'field'   => 'category',
  *          'value'   => 'catalog_2013,catalog_2014',
  *          'options' => null
  *      ],
  * ]
  *
  * @param ProductInterface $product
  * @param array            $configuration
  *
  * @throws \LogicException
  *
  * @return ProductInterface $product
  */
 protected function updateProduct(ProductInterface $product, array $configuration)
 {
     $modifiedAttributesNb = 0;
     foreach ($configuration['actions'] as $action) {
         $attribute = $this->attributeRepository->findOneBy(['code' => $action['field']]);
         if (null === $attribute) {
             throw new \LogicException(sprintf('Attribute with code %s does not exist'), $action['field']);
         }
         if ($product->isAttributeEditable($attribute)) {
             $localizer = $this->localizerRegistry->getLocalizer($attribute->getAttributeType());
             if (null !== $localizer) {
                 $action['value'] = $localizer->delocalize($action['value'], ['locale' => $configuration['locale']]);
             }
             $this->propertySetter->setData($product, $action['field'], $action['value'], $action['options']);
             $modifiedAttributesNb++;
         }
     }
     if (0 === $modifiedAttributesNb) {
         $this->stepExecution->incrementSummaryInfo('skipped_products');
         $this->stepExecution->addWarning($this->getName(), 'pim_enrich.mass_edit_action.edit-common-attributes.message.no_valid_attribute', [], $product);
         return null;
     }
     return $product;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:50,代码来源:EditCommonAttributesProcessor.php

示例7: getIdentifierAttribute

 /**
  * Return the identifier attribute
  *
  * @return AttributeInterface|null
  */
 protected function getIdentifierAttribute()
 {
     return $this->attributeRepository->findOneBy(['attributeType' => AttributeTypes::IDENTIFIER]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:9,代码来源:ProductRepository.php


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