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


PHP Repository\IdentifiableObjectRepositoryInterface类代码示例

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


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

示例1:

 function it_builds_form(FormBuilderInterface $builder, IdentifiableObjectRepositoryInterface $repository, DataTransformerInterface $transformer, $transformerFactory)
 {
     $options = ['repository' => $repository->getWrappedObject(), 'multiple' => false];
     $transformerFactory->create($repository, ['multiple' => false])->willReturn($transformer);
     $builder->addViewTransformer($transformer, true)->shouldBeCalled();
     $this->buildForm($builder, $options);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:AsyncSelectTypeSpec.php

示例2: let

 function let(IdentifiableObjectRepositoryInterface $repository, \stdClass $entity)
 {
     $entity->code = 'foo';
     $repository->getIdentifierProperties()->willReturn(['code']);
     $repository->findOneByIdentifier('foo')->willReturn($entity);
     $this->beConstructedWith($repository, ['multiple' => false]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:IdentifiableModelTransformerSpec.php

示例3: findObject

 /**
  * Find an object according to its identifiers from a repository.
  *
  * @param IdentifiableObjectRepositoryInterface $repository the repository to search inside
  * @param array                                 $data       the data that is currently processed
  *
  * @throws MissingIdentifierException in case the processed data do not allow to retrieve an object
  *                                    by its identifiers properly
  *
  * @return object|null
  */
 protected function findObject(IdentifiableObjectRepositoryInterface $repository, array $data)
 {
     $properties = $repository->getIdentifierProperties();
     $references = [];
     foreach ($properties as $property) {
         if (!isset($data[$property])) {
             throw new MissingIdentifierException(sprintf('Missing identifier column "%s". Columns found: %s.', $property, implode(', ', array_keys($data))));
         }
         $references[] = $data[$property];
     }
     return $repository->findOneByIdentifier(implode('.', $references));
 }
开发者ID:pierallard,项目名称:pim-community-dev,代码行数:23,代码来源:AbstractProcessor.php

示例4: findObject

 /**
  * Find an object according to its identifiers from a repository.
  *
  * @param IdentifiableObjectRepositoryInterface $repository the repository to search inside
  * @param array                                 $data       the data that is currently processed
  *
  * @throws MissingIdentifierException in case the processed data do not allow to retrieve an object
  *                                    by its identifiers properly
  *
  * @return object|null
  */
 protected function findObject(IdentifiableObjectRepositoryInterface $repository, array $data)
 {
     $properties = $repository->getIdentifierProperties();
     $references = [];
     foreach ($properties as $property) {
         if (!isset($data[$property])) {
             throw new MissingIdentifierException();
         }
         $references[] = $data[$property];
     }
     return $repository->findOneByIdentifier(implode('.', $references));
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:23,代码来源:AbstractProcessor.php

示例5:

 function it_returns_no_products_when_they_all_are_duplicated($productRepository, $paginatorFactory, $stepExecution, ProductInterface $product, $pqbFactory, ProductQueryBuilder $pqb, ProductQueryBuilder $pqb2, Cursor $cursor, Cursor $cursor2, JobParameters $jobParameters, IdentifiableObjectRepositoryInterface $groupRepository, GroupInterface $variantGroup, AttributeInterface $axe, PaginatorInterface $paginator)
 {
     $configuration = ['filters' => [['field' => 'id', 'operator' => 'IN', 'value' => [12, 13]]], 'actions' => ['value' => 'variantGroupCode']];
     $stepExecution->getJobParameters()->willReturn($jobParameters);
     $jobParameters->get('filters')->willReturn($configuration['filters']);
     $jobParameters->get('actions')->willReturn($configuration['actions']);
     $groupRepository->findOneByIdentifier('variantGroupCode')->willReturn($variantGroup);
     $variantGroup->getAxisAttributes()->willReturn([$axe]);
     $variantGroup->getId()->willReturn(42);
     $axe->getCode()->willReturn('axe');
     $productRepository->getEligibleProductIdsForVariantGroup(42)->willReturn([]);
     $pqbFactory->create(['filters' => $configuration['filters']])->willReturn($pqb);
     $pqb->execute()->willReturn($cursor);
     $paginatorFactory->createPaginator($cursor)->willReturn($paginator);
     $pqbFactory->create(['filters' => [['field' => 'id', 'operator' => 'IN', 'value' => ['']]]])->willReturn($pqb2);
     $pqb2->execute()->willReturn($cursor2);
     $this->initialize();
     $this->read()->shouldReturn(null);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:19,代码来源:FilteredVariantGroupProductReaderSpec.php

示例6: getAttributeLabelFromCode

 /**
  * @param string $code
  *
  * @return string
  */
 public function getAttributeLabelFromCode($code)
 {
     if (null !== ($attribute = $this->attributeRepository->findOneByIdentifier($code))) {
         return (string) $attribute;
     }
     return $code;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:12,代码来源:AttributeExtension.php

示例7: transform

 /**
  * {@inheritdoc}
  */
 public function transform($model)
 {
     if (null === $model) {
         return null;
     }
     if (count($this->repository->getIdentifierProperties()) > 1) {
         throw new \InvalidArgumentException('Cannot transform object with multiple identifiers');
     }
     $identifierProperty = $this->repository->getIdentifierProperties()[0];
     $propertyAccessor = PropertyAccess::createPropertyAccessor();
     if ($this->multiple) {
         if (!is_array($model)) {
             throw new UnexpectedTypeException($model, 'array');
         }
         $identifiers = [];
         foreach ($model as $object) {
             $identifiers[] = $propertyAccessor->getValue($object, $identifierProperty);
         }
         return $identifiers;
     }
     if (!is_object($model)) {
         throw new UnexpectedTypeException($model, 'object');
     }
     return $propertyAccessor->getValue($model, $identifierProperty);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:28,代码来源:IdentifiableModelTransformer.php

示例8: findVariantGroupOr404

 /**
  * Find a variant group by its id or return a 404 response
  *
  * @param string $code
  *
  * @throws NotFoundHttpException
  *
  * @return GroupInterface
  */
 protected function findVariantGroupOr404($code)
 {
     $group = $this->groupRepository->findOneByIdentifier($code);
     if (null === $group || false === $group->getType()->isVariant()) {
         throw new NotFoundHttpException(sprintf('Variant group with id %d could not be found.', $id));
     }
     return $group;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:VariantGroupAttributeController.php

示例9: setFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : "family_code"
  */
 public function setFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     if (null !== $data) {
         $family = $this->familyRepository->findOneByIdentifier($data);
         if (null === $family) {
             throw InvalidArgumentException::expected($field, 'existing family code', 'setter', 'family', $data);
         }
         $product->setFamily($family);
     } else {
         $product->setFamily(null);
     }
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:18,代码来源:FamilyFieldSetter.php

示例10: removeFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["category_code", "another_category_code"]
  */
 public function removeFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     $categories = [];
     foreach ($data as $categoryCode) {
         $category = $this->categoryRepository->findOneByIdentifier($categoryCode);
         if (null === $category) {
             throw InvalidArgumentException::expected($field, 'existing category code', 'remover', 'category', $categoryCode);
         }
         $categories[] = $category;
     }
     foreach ($categories as $categoryToRemove) {
         $product->removeCategory($categoryToRemove);
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:20,代码来源:CategoryFieldRemover.php

示例11: findGroup

 /**
  * @param string $code
  *
  * @return Group|null
  */
 protected function findGroup($code)
 {
     $group = $this->groupRepository->findOneByIdentifier($code);
     if (null === $group) {
         throw new \InvalidArgumentException(sprintf('Group %s was not found', $code));
     }
     return $group;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:13,代码来源:UserUpdater.php

示例12: sort

 /**
  * {@inheritdoc}
  */
 public function sort(array $columns, array $context = [])
 {
     $identifier = $this->productRepository->getIdentifierProperties()[0];
     if (isset($context['filters']['structure']['attributes']) && !empty($context['filters']['structure']['attributes'])) {
         $rawColumns = array_merge([$identifier], $this->firstDefaultColumns, array_map(function ($associationType) {
             return $associationType->getCode();
         }, $this->associationTypeRepository->findAll()), $context['filters']['structure']['attributes']);
         $sortedColumns = [];
         foreach ($rawColumns as $columnCode) {
             $sortedColumns = array_merge($sortedColumns, array_filter($columns, function ($columnCandidate) use($columnCode) {
                 return 0 !== preg_match(sprintf('/^%s(-.*)*/', $columnCode), $columnCandidate);
             }));
         }
         return $sortedColumns;
     }
     array_unshift($this->firstDefaultColumns, $identifier);
     return parent::sort($columns);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:21,代码来源:ProductColumnSorter.php

示例13: addFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["group_code"]
  */
 public function addFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     $groups = [];
     foreach ($data as $groupCode) {
         $group = $this->groupRepository->findOneByIdentifier($groupCode);
         if (null === $group) {
             throw InvalidArgumentException::expected($field, 'existing group code', 'adder', 'groups', $groupCode);
         } elseif ($group->getType()->isVariant()) {
             throw InvalidArgumentException::expected($field, 'non variant group code', 'adder', 'groups', $groupCode);
         } else {
             $groups[] = $group;
         }
     }
     foreach ($groups as $group) {
         $product->addGroup($group);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:GroupFieldAdder.php

示例14: execute

 /**
  * @param array $configuration
  */
 public function execute(array $configuration)
 {
     $actions = $configuration['actions'];
     $variantGroupCode = $actions['value'];
     $variantGroup = $this->groupRepository->findOneByIdentifier($variantGroupCode);
     $axisAttributeCodes = $this->getAxisAttributeCodes($variantGroup);
     $eligibleProductIds = $this->productRepository->getEligibleProductIdsForVariantGroup($variantGroup->getId());
     $cursor = $this->getProductsCursor($configuration['filters']);
     $paginator = $this->paginatorFactory->createPaginator($cursor);
     list($productAttributeAxis, $acceptedIds) = $this->filterDuplicateAxisCombinations($paginator, $eligibleProductIds, $axisAttributeCodes);
     $excludedIds = $this->addSkippedMessageForDuplicatedProducts($productAttributeAxis);
     $acceptedIds = array_diff($acceptedIds, $excludedIds);
     $configuration['filters'] = [['field' => 'id', 'operator' => 'IN', 'value' => $acceptedIds]];
     if (0 === count($acceptedIds)) {
         $configuration = null;
     }
     $this->setJobConfiguration(json_encode($configuration));
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:21,代码来源:VariantGroupCleaner.php

示例15: setAssociatedGroups

 /**
  * @param AssociationInterface $association
  * @param array                $groupsCodes
  */
 protected function setAssociatedGroups(AssociationInterface $association, $groupsCodes)
 {
     foreach ($groupsCodes as $groupCode) {
         $associatedGroup = $this->groupRepository->findOneByIdentifier($groupCode);
         if (!$associatedGroup) {
             throw InvalidArgumentException::expected('associations', 'existing group code', 'setter', 'association', $groupCode);
         }
         $association->addGroup($associatedGroup);
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:14,代码来源:AssociationFieldSetter.php


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