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


PHP Collection::map方法代码示例

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


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

示例1: synchronizeOptions

 protected function synchronizeOptions(Collection $options)
 {
     $this->options->map(function (VariantOptionInterface $option) use($options) {
         if (false === $options->contains($option)) {
             $this->options->removeElement($option);
         }
     });
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:8,代码来源:Variant.php

示例2: testMap

 public function testMap()
 {
     $this->_coll->add(1);
     $this->_coll->add(2);
     $res = $this->_coll->map(function ($e) {
         return $e * 2;
     });
     $this->assertEquals(array(2, 4), $res->toArray());
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:9,代码来源:CollectionTest.php

示例3: setValues

 /**
  * {@inheritdoc}
  */
 public function setValues(Collection $collection)
 {
     if (null !== $this->values) {
         $this->values->map(function (AttributeValueInterface $value) use($collection) {
             if (false === $collection->contains($value)) {
                 $this->removeValue($value);
             }
         });
     }
     $this->values = $collection;
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:14,代码来源:Attribute.php

示例4: setAttributes

 /**
  * {@inheritdoc}
  */
 public function setAttributes(Collection $attributes)
 {
     if ($this->attributes instanceof Collection) {
         $this->attributes->map(function (AttributeInterface $attribute) use($attributes) {
             if (false === $attributes->contains($attribute)) {
                 $this->removeAttribute($attribute);
             }
         });
     }
     $this->attributes = $attributes;
 }
开发者ID:WellCommerce,项目名称:AttributeBundle,代码行数:14,代码来源:AttributeGroup.php

示例5: map

 /**
  * {@inheritDoc}
  */
 public function map(Closure $func)
 {
     $mapped = $this->collection->map($func);
     // validate mapped elements
     array_map($this->getIdentityExtractor(), $mapped->toArray());
     return new static($mapped);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:10,代码来源:IdentityWrapper.php

示例6: setDomains

 /**
  * Twitter requires domains without scheme
  *
  * @param Doctrine\Common\Collections\Collection
  */
 public function setDomains(Collection $domains)
 {
     $remap = $domains->map(function ($item) {
         return str_replace(array("https://", "http://"), '', $item);
     }, $domains);
     $this->domains = $remap;
 }
开发者ID:antimattr,项目名称:twitter-marketplace,代码行数:12,代码来源:Merchant.php

示例7: generateTree

 /**
  * Generates a tree for given children elements
  *
  * @param Collection $collection
  * @param Collection $children
  *
  * @return array
  */
 protected function generateTree(Collection $collection, Collection $children)
 {
     $children->map(function (AdminMenuInterface $menuItem) use($collection, &$tree) {
         $tree[] = ['routeName' => $menuItem->getRouteName(), 'cssClass' => $menuItem->getCssClass(), 'name' => $menuItem->getName(), 'children' => $this->generateTree($collection, $this->filterElements($collection, $menuItem))];
     });
     return $tree;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:15,代码来源:AdminMenuProvider.php

示例8: getCollectionValue

 protected function getCollectionValue(Collection $collection)
 {
     $value = 0;
     $collection->map(function (ReportRow $row) use(&$value) {
         $value += $row->getValue();
     });
     return $value;
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:8,代码来源:SalesSummaryCalculator.php

示例9: processConfiguration

 /**
  * {@inheritdoc}
  */
 public function processConfiguration(Collection $collection)
 {
     $config = [];
     $collection->map(function (PaymentMethodConfigurationInterface $configuration) use(&$config) {
         $config[$configuration->getName()] = $configuration->getValue();
     });
     return $config;
 }
开发者ID:pguso,项目名称:WellCommerce,代码行数:11,代码来源:AbstractPaymentProcessor.php

示例10: getShippingCostWeight

 /**
  * {@inheritdoc}
  */
 public function getShippingCostWeight()
 {
     $weight = 0;
     $this->products->map(function (OrderProduct $orderProduct) use(&$weight) {
         $weight += $orderProduct->getQuantity() * $orderProduct->getWeight();
     });
     return $weight;
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:11,代码来源:Order.php

示例11: getTotal

 /**
  * @return Money
  */
 public function getTotal() : Money
 {
     $total = new Money(0);
     $this->lineItems->map(function (LineItem $lineItem) use(&$total) {
         $total = $total->add($lineItem->getPrice());
     });
     return $total;
 }
开发者ID:igaponov,项目名称:shop,代码行数:11,代码来源:Order.php

示例12: syncNewAttributes

 protected function syncNewAttributes(Collection $attributes)
 {
     $attributes->map(function (AttributeInterface $attribute) {
         if (false === $this->attributes->contains($attribute)) {
             $attribute->addValue($this);
         }
     });
 }
开发者ID:WellCommerce,项目名称:AttributeBundle,代码行数:8,代码来源:AttributeValue.php

示例13: getCurrencies

 /**
  * Get currencies
  *
  * @return array|string[]
  */
 public function getCurrencies()
 {
     $currencies = $this->currencies->map(function (PriceListCurrency $priceListCurrency) {
         return $priceListCurrency->getCurrency();
     })->toArray();
     sort($currencies);
     return $currencies;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:13,代码来源:PriceList.php

示例14: getAttributeValues

 protected function getAttributeValues(Collection $collection)
 {
     $values = [];
     $collection->map(function (AttributeValueInterface $value) use(&$values) {
         $values[] = ['id' => $value->getId(), 'name' => $value->translate()->getName()];
     });
     return $values;
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:8,代码来源:AttributeRepository.php

示例15: extractValues

 /**
  * Extracts information from collection and appends it to an array of attributes
  *
  * @param Collection $collection
  * @param array      $attributes
  */
 protected function extractValues(Collection $collection, &$attributes)
 {
     $collection->map(function (AttributeValueInterface $attributeValue) use(&$attributes) {
         $attribute = $attributeValue->getAttribute();
         $attributes[$attribute->getId()]['name'] = $attribute->translate()->getName();
         $attributes[$attribute->getId()]['values'][$attributeValue->getId()] = $attributeValue->translate()->getName();
     });
 }
开发者ID:Sywooch,项目名称:WellCommerce,代码行数:14,代码来源:ProductAttributeHelper.php


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