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


PHP AttributeInterface::getOptions方法代碼示例

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


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

示例1: updateSorting

 /**
  * Update attribute option sorting
  *
  * @param AttributeInterface $attribute
  * @param array              $sorting
  */
 public function updateSorting(AttributeInterface $attribute, array $sorting = [])
 {
     foreach ($attribute->getOptions() as $option) {
         if (isset($sorting[$option->getId()])) {
             $option->setSortOrder($sorting[$option->getId()]);
         } else {
             $option->setSortOrder(0);
         }
     }
     $this->optionSaver->saveAll($attribute->getOptions()->toArray());
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:17,代碼來源:AttributeOptionsSorter.php

示例2: __construct

 /**
  * @param AttributeRepositoryInterface $attributeRepository
  * @param AttributeOptionRepositoryInterface $attributeOptionRepository
  * @param string $attributeCode
  * @param FileLoader $loader
  * @param string $mappingFile
  */
 public function __construct(AttributeRepositoryInterface $attributeRepository, AttributeOptionRepositoryInterface $attributeOptionRepository, $attributeCode, FileLoader $loader = null, $mappingFile = null)
 {
     $this->attributeRepository = $attributeRepository;
     $this->attributeOptionRepository = $attributeOptionRepository;
     $this->mapping = [];
     $this->attribute = $this->attributeRepository->findOneByIdentifier($attributeCode);
     if ($this->attribute) {
         $this->attributeOptions = $this->attribute->getOptions();
     } else {
         $this->attributeOptions = new ArrayCollection();
     }
     if ($mappingFile !== null && $loader !== null) {
         foreach ($loader->load($mappingFile) as $rawValue => $optionCode) {
             $this->mapTo($rawValue, $optionCode);
         }
     }
 }
開發者ID:lunistore,項目名稱:akeneo-connector-base,代碼行數:24,代碼來源:AttributeOptionDiscoverer.php

示例3: normalizeOptions

 /**
  * {@inheritdoc}
  */
 protected function normalizeOptions(AttributeInterface $attribute)
 {
     $options = $attribute->getOptions();
     if ($options->isEmpty()) {
         $options = '';
     } else {
         $data = [];
         foreach ($options as $option) {
             $item = [];
             foreach ($option->getOptionValues() as $value) {
                 $label = str_replace('{locale}', $value->getLocale(), self::LOCALIZABLE_PATTERN);
                 $label = str_replace('{value}', $value->getValue(), $label);
                 $item[] = $label;
             }
             $data[] = 'Code:' . $option->getCode() . self::ITEM_SEPARATOR . implode(self::ITEM_SEPARATOR, $item);
         }
         $options = implode(self::GROUP_SEPARATOR, $data);
     }
     return $options;
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:23,代碼來源:AttributeNormalizer.php

示例4: normalizeOptions

 /**
  * Normalize options
  *
  * @param AttributeInterface $attribute
  *
  * @return array
  */
 protected function normalizeOptions(AttributeInterface $attribute)
 {
     $data = [];
     $options = $attribute->getOptions();
     foreach ($options as $option) {
         $data[$option->getCode()] = [];
         foreach ($option->getOptionValues() as $value) {
             $data[$option->getCode()][$value->getLocale()] = $value->getValue();
         }
     }
     return $data;
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:19,代碼來源:AttributeNormalizer.php


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