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


PHP Collection::set方法代码示例

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


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

示例1: addProduct

 /**
  * Add a product to the basket.
  *
  * @param Product $product
  * @param int     $nb
  *
  * @return $this
  */
 public function addProduct(Product $product, $nb = 1)
 {
     if (!$this->products->containsKey($product->getId())) {
         $this->products->set($product->getId(), $product);
     }
     $this->increaseNbProduct($product, $nb);
     return $this;
 }
开发者ID:Neirda24,项目名称:currency,代码行数:16,代码来源:Basket.php

示例2: addTemplateLayout

 /**
  * Set templateLayout
  * @param TemplateLayout $templateLayout
  */
 public function addTemplateLayout(TemplateLayout $templateLayout)
 {
     if ($this->lock('templateLayouts')) {
         $media = $templateLayout->getMedia();
         $this->templateLayouts->set($media, $templateLayout);
         $templateLayout->setTemplate($this);
         $this->unlock('templateLayouts');
     }
 }
开发者ID:sitesupra,项目名称:sitesupra,代码行数:13,代码来源:Template.php

示例3: map

 /**
  * {@inheritdoc}
  */
 public function map(array $packagesInfo, ConfigurationInterface $config)
 {
     $this->config = $config;
     $packagesInfo = $this->orderPackages($packagesInfo);
     foreach ($packagesInfo[self::DEPENDENCIES_KEY] as $packageName => $packageInfo) {
         $package = $this->createPackage($packageName, $packageInfo);
         $this->packages->set($packageName, $package);
     }
     return $this->packages;
 }
开发者ID:boskee,项目名称:SpBowerBundle,代码行数:13,代码来源:DependencyMapper.php

示例4: addProduct

 /**
  * @param Product $product
  * @param Quantity $quantity
  * @return Cart
  */
 public function addProduct(Product $product, Quantity $quantity) : Cart
 {
     $key = $product->getId()->getValue();
     /** @var LineItem $lineItem */
     $lineItem = $this->lineItems->get($key);
     if ($lineItem === null) {
         $lineItem = new LineItem($product, $quantity);
     } else {
         $lineItem = new LineItem($product, $lineItem->getQuantity()->add($quantity));
     }
     $this->lineItems->set($key, $lineItem);
     return $this;
 }
开发者ID:igaponov,项目名称:shop,代码行数:18,代码来源:Cart.php

示例5: addSystem

 /**
  * @param \common\entities\System $system
  * @param bool $sync
  */
 public function addSystem(System $system, $sync = true)
 {
     $this->systems->set($system->getNumber(), $system);
     if ($sync) {
         $system->setGalaxy($this, false);
     }
 }
开发者ID:iw-reload,项目名称:iw,代码行数:11,代码来源:Galaxy.php

示例6: addCelestialBody

 /**
  * @param \common\entities\System $celestialBody
  * @param bool $sync
  */
 public function addCelestialBody(CelestialBody $celestialBody, $sync = true)
 {
     $this->celestialBodies->set($celestialBody->getNumber(), $celestialBody);
     if ($sync) {
         $celestialBody->setSystem($this, false);
     }
 }
开发者ID:iw-reload,项目名称:iw,代码行数:11,代码来源:System.php

示例7: addGalaxy

 /**
  * @param \common\entities\Galaxy $galaxy
  * @param bool $sync
  */
 public function addGalaxy(Galaxy $galaxy, $sync = true)
 {
     $this->galaxies->set($galaxy->getNumber(), $galaxy);
     if ($sync) {
         $galaxy->setUniverse($this, false);
     }
 }
开发者ID:iw-reload,项目名称:iw,代码行数:11,代码来源:Universe.php

示例8: addTranslation

 /**
  * @param TranslationInterface $translation
  */
 public function addTranslation(TranslationInterface $translation)
 {
     if (!$this->translations->containsKey($translation->getLocale())) {
         $this->translations->set($translation->getLocale(), $translation);
         $translation->setTranslatable($this);
     }
 }
开发者ID:php-lug,项目名称:lug,代码行数:10,代码来源:TranslatableTrait.php

示例9: createNewContainer

 /**
  * @param int $index
  * @return \Kdyby\Doctrine\Forms\EntityContainer
  */
 private function createNewContainer($index)
 {
     if (!$this->collection->containsKey($index)) {
         $this->collection->set($index, $this->createNewEntity());
     }
     $class = $this->containerClass;
     return new $class($this->collection->get($index));
 }
开发者ID:svobodni,项目名称:web,代码行数:12,代码来源:CollectionContainer.php

示例10: set

 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     $this->coll->set($key, $value);
     // Handle orphanRemoval
     if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) {
         $this->uow->unscheduleOrphanRemoval($value);
     }
     $this->changed();
 }
开发者ID:dominium,项目名称:mongodb-odm,代码行数:12,代码来源:PersistentCollectionTrait.php

示例11: doSet

 /**
  * Actual logic for setting an element in the collection.
  *
  * @param mixed $offset
  * @param mixed $value
  * @param bool $arrayAccess
  * @return bool
  */
 private function doSet($offset, $value, $arrayAccess)
 {
     $arrayAccess ? $this->coll->offsetSet($offset, $value) : $this->coll->set($offset, $value);
     // Handle orphanRemoval
     if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) {
         $this->uow->unscheduleOrphanRemoval($value);
     }
     $this->changed();
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:17,代码来源:PersistentCollectionTrait.php

示例12: set

 /**
  * Sets an element in the collection at the specified key/index.
  *
  * @param string|integer $key The key/index of the element to set.
  * @param mixed $value The element to set.
  *
  * @return void
  */
 function set($key, $value)
 {
     $this->checkType($value);
     $this->initialize();
     $className = $this->entityTerms->getClassName();
     $eTerm = new $className();
     /** @var $eTerm EntityTermRepositoryInterface */
     $eTerm->setTerm($value);
     $this->collection->set($key, $eTerm);
 }
开发者ID:activelamp,项目名称:taxonomy,代码行数:18,代码来源:PluralVocabularyField.php

示例13: partition

 /**
  * {@inheritDoc}
  */
 public function partition(Closure $p)
 {
     $array = $this->toArray();
     $this->collection->clear();
     foreach ($array as $key => $element) {
         $this->collection->set($key, $element);
     }
     $partitions = $this->collection->partition($p);
     return [new static($partitions[0]), new static($partitions[1])];
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:13,代码来源:IdentityWrapper.php

示例14: fixCollectionField

 /**
  * @param Collection $collection
  * @param $level
  */
 protected function fixCollectionField($collection, $level)
 {
     foreach ($collection as $key => $value) {
         if ($this->isEntityDetached($value)) {
             $value = $this->reloadEntity($value);
             $collection->set($key, $value);
         } else {
             $this->fixEntityAssociationFields($value, $level - 1);
         }
     }
 }
开发者ID:sagikazarmark,项目名称:platform,代码行数:15,代码来源:EntityDetachFixer.php

示例15: addChild

 /**
  * {@inheritdoc}
  */
 public function addChild($child, array $options = array())
 {
     if (!$this->hasChild($child)) {
         $child->setParent($this);
         $this->children->set($child->getName(), $child);
     }
     return $child;
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:11,代码来源:MenuItem.php


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