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


PHP IdentifiableObjectRepositoryInterface::getIdentifierProperties方法代碼示例

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


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

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

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

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

示例6: getIdentifier

 /**
  * @param array $convertedItem
  *
  * @return string
  */
 protected function getIdentifier(array $convertedItem)
 {
     $identifierProperty = $this->repository->getIdentifierProperties();
     return $convertedItem[$identifierProperty[0]];
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:10,代碼來源:ProductAssociationProcessor.php

示例7: sort

 /**
  * {@inheritdoc}
  */
 public function sort(array $columns)
 {
     $identifier = $this->productRepository->getIdentifierProperties()[0];
     array_unshift($this->firstDefaultColumns, $identifier);
     return parent::sort($columns);
 }
開發者ID:pierallard,項目名稱:pim-community-dev,代碼行數:9,代碼來源:ProductColumnSorter.php

示例8: getIdentifier

 /**
  * @param array $item
  *
  * @return string
  */
 protected function getIdentifier(array $item)
 {
     $identifierProperty = $this->repository->getIdentifierProperties();
     return $item[$identifierProperty[0]][0]['data'];
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:10,代碼來源:ProductAssociationProcessor.php


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