當前位置: 首頁>>代碼示例>>PHP>>正文


PHP IdentifiableObjectRepositoryInterface::findOneByIdentifier方法代碼示例

本文整理匯總了PHP中Akeneo\Component\StorageUtils\Repository\IdentifiableObjectRepositoryInterface::findOneByIdentifier方法的典型用法代碼示例。如果您正苦於以下問題:PHP IdentifiableObjectRepositoryInterface::findOneByIdentifier方法的具體用法?PHP IdentifiableObjectRepositoryInterface::findOneByIdentifier怎麽用?PHP IdentifiableObjectRepositoryInterface::findOneByIdentifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Akeneo\Component\StorageUtils\Repository\IdentifiableObjectRepositoryInterface的用法示例。


在下文中一共展示了IdentifiableObjectRepositoryInterface::findOneByIdentifier方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

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

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

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

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

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

示例7: reverseTransform

 /**
  * {@inheritdoc}
  */
 public function reverseTransform($identifier)
 {
     if (null === $identifier) {
         return null;
     }
     if (true === $this->multiple) {
         if (!is_array($identifier)) {
             throw new UnexpectedTypeException($identifier, 'array');
         }
         $models = [];
         foreach ($identifier as $scalarIdentifier) {
             $models[] = $this->repository->findOneByIdentifier($scalarIdentifier);
         }
         return $models;
     }
     return $this->repository->findOneByIdentifier($identifier);
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:20,代碼來源:IdentifiableModelTransformer.php

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

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

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

示例11: setFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : ["group_code"]
  */
 public function setFieldData(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', 'setter', 'groups', $groupCode);
         } else {
             $groups[] = $group;
         }
     }
     $oldGroups = $product->getGroups();
     foreach ($oldGroups as $group) {
         $product->removeGroup($group);
     }
     foreach ($groups as $group) {
         $product->addGroup($group);
     }
 }
開發者ID:noglitchyo,項目名稱:pim-community-dev,代碼行數:25,代碼來源:GroupFieldSetter.php

示例12: setLocales

 /**
  * @param ChannelInterface $channel
  * @param array            $localeCodes
  */
 protected function setLocales(ChannelInterface $channel, array $localeCodes)
 {
     $locales = [];
     foreach ($localeCodes as $localeCode) {
         $locale = $this->localeRepository->findOneByIdentifier($localeCode);
         if (null === $locale) {
             throw new \InvalidArgumentException(sprintf('Locale with "%s" code does not exist', $localeCode));
         }
         $locales[] = $locale;
     }
     $channel->setLocales($locales);
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:16,代碼來源:ChannelUpdater.php

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

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

示例15: setFieldData

 /**
  * {@inheritdoc}
  *
  * Expected data input format : "variant_group_code"
  */
 public function setFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     if (null !== $data) {
         $variantGroup = $this->groupRepository->findOneByIdentifier($data);
         if (null === $variantGroup) {
             throw InvalidArgumentException::expected($field, 'existing variant group code', 'setter', 'variant_group', $data);
         }
         if (!$variantGroup->getType()->isVariant()) {
             throw InvalidArgumentException::expected($field, 'variant group code', 'setter', 'variant_group', $data);
         }
     }
     $existingGroups = $product->getGroups();
     foreach ($existingGroups as $group) {
         if ($group->getType()->isVariant()) {
             $product->removeGroup($group);
         }
     }
     if (null !== $data) {
         $product->addGroup($variantGroup);
     }
 }
開發者ID:vpetrovych,項目名稱:pim-community-dev,代碼行數:27,代碼來源:VariantGroupFieldSetter.php


注:本文中的Akeneo\Component\StorageUtils\Repository\IdentifiableObjectRepositoryInterface::findOneByIdentifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。