當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。