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


PHP Collection::remove方法代碼示例

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


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

示例1: removeProduct

 /**
  * Remove a product from the basket.
  *
  * @param Product $product
  * @param int     $nb
  *
  * @return $this
  */
 public function removeProduct(Product $product, $nb = 1)
 {
     if ($this->products->containsKey($product->getId())) {
         $this->decreaseNbProduct($product, $nb);
         $nbLeft = $this->getNbProduct($product);
         if (0 >= $nbLeft) {
             $this->products->remove($product->getId());
         }
     }
     return $this;
 }
開發者ID:Neirda24,項目名稱:currency,代碼行數:19,代碼來源:Basket.php

示例2: intersectUnion

 /**
  * This function performs a kind of "intersection union" operation, and is useful especially when dealing
  * with dynamic forms. For instance, if a collection contains existing elements and a form remove one of those
  * elements, this function will return a Collection that contains all the elements from $collection1, minus ones
  * that are not present in $collection2. This is used internally in the DoctrineModule hydrator, so that the
  * work is done for you automatically
  *
  * @param  Collection $collection1
  * @param  Collection $collection2
  * @return Collection
  */
 public static function intersectUnion(Collection $collection1, Collection $collection2)
 {
     // Don't make the work both
     if ($collection1 === $collection2) {
         return $collection1;
     }
     $toRemove = array();
     foreach ($collection1 as $key1 => $value1) {
         $elementFound = false;
         foreach ($collection2 as $key2 => $value2) {
             if ($value1 === $value2) {
                 $elementFound = true;
                 unset($collection2[$key2]);
                 break;
             }
         }
         if (!$elementFound) {
             $toRemove[] = $key1;
         }
     }
     // Remove elements that are in $collection1 but not in $collection2
     foreach ($toRemove as $key) {
         $collection1->remove($key);
     }
     // Add elements that are in $collection2 but not in $collection1
     foreach ($collection2 as $value) {
         $collection1->add($value);
     }
     return $collection1;
 }
開發者ID:rrmodi88,項目名稱:DoctrineModule,代碼行數:41,代碼來源:CollectionUtils.php

示例3: remove

 /**
  * Removes the element at the specified index from the collection.
  *
  * @param string|integer $key The kex/index of the element to remove.
  *
  * @return mixed The removed element or NULL, if the collection did not contain the element.
  */
 function remove($key)
 {
     $this->initialize();
     $element = $this->collection->remove($key);
     if ($element) {
         $this->setDirty(true);
     }
     return $element;
 }
開發者ID:activelamp,項目名稱:taxonomy,代碼行數:16,代碼來源:PluralVocabularyField.php

示例4: testRemove

 public function testRemove()
 {
     $this->_coll[] = 'one';
     $this->_coll[] = 'two';
     $el = $this->_coll->remove(0);
     $this->assertEquals('one', $el);
     $this->assertEquals($this->_coll->contains('one'), false);
     $this->assertNull($this->_coll->remove(0));
 }
開發者ID:GMBN,項目名稱:ZF2---DoctrineModule---ManyToOne-,代碼行數:9,代碼來源:CollectionTest.php

示例5: remove

 /**
  * {@inheritdoc}
  */
 public function remove($key)
 {
     $this->initialize();
     $removed = $this->coll->remove($key);
     if (!$removed) {
         return $removed;
     }
     $this->changed();
     return $removed;
 }
開發者ID:dominium,項目名稱:mongodb-odm,代碼行數:13,代碼來源:PersistentCollectionTrait.php

示例6: doRemove

 /**
  * Actual logic for removing element by its key.
  *
  * @param mixed $offset
  * @param bool $arrayAccess
  * @return mixed|void
  */
 private function doRemove($offset, $arrayAccess)
 {
     $this->initialize();
     $removed = $arrayAccess ? $this->coll->offsetUnset($offset) : $this->coll->remove($offset);
     if (!$removed && !$arrayAccess) {
         return $removed;
     }
     $this->changed();
     return $removed;
 }
開發者ID:alcaeus,項目名稱:mongodb-odm,代碼行數:17,代碼來源:PersistentCollectionTrait.php

示例7: remove

 /**
  * {@inheritdoc}
  */
 public function remove($key)
 {
     $this->initialize();
     $removed = $this->coll->remove($key);
     if ($removed) {
         $this->changed();
         if ($this->isOrphanRemovalEnabled()) {
             $this->uow->scheduleOrphanRemoval($removed);
         }
     }
     return $removed;
 }
開發者ID:im286er,項目名稱:ent,代碼行數:15,代碼來源:PersistentCollection.php

示例8: removeModifier

 public function removeModifier(string $name)
 {
     $this->modifiers->remove($name);
 }
開發者ID:wellcommerce,項目名稱:wellcommerce,代碼行數:4,代碼來源:Order.php

示例9: remove

 public function remove($key)
 {
     $this->initialize();
     $this->changed = true;
     return $this->col->remove($key);
 }
開發者ID:doctrine,項目名稱:couchdb-odm,代碼行數:6,代碼來源:PersistentCollection.php

示例10: remove

 /**
  * {@inheritdoc}
  */
 public function remove($key)
 {
     // TODO: If the keys are persistent as well (not yet implemented)
     //       and the collection is not initialized and orphanRemoval is
     //       not used we can issue a straight SQL delete/update on the
     //       association (table). Without initializing the collection.
     $this->initialize();
     $removed = $this->coll->remove($key);
     if ($removed) {
         $this->changed();
         if ($this->association !== null && $this->association['type'] == ClassMetadata::ONE_TO_MANY && $this->association['orphanRemoval']) {
             $this->em->getUnitOfWork()->scheduleOrphanRemoval($removed);
         }
     }
     return $removed;
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:19,代碼來源:PersistentCollection.php

示例11: removeChild

 /**
  * {@inheritdoc}
  */
 public function removeChild($name)
 {
     $name = $name instanceof ItemInterface ? $name->getName() : $name;
     $child = $this->getChild($name);
     if ($child !== null) {
         $child->setParent(null);
         $this->children->remove($name);
     }
     return $this;
 }
開發者ID:superdesk,項目名稱:web-publisher,代碼行數:13,代碼來源:MenuItem.php

示例12: removeReview

 /**
  * {@inheritdoc}
  */
 public function removeReview(ReviewInterface $review)
 {
     $this->reviews->remove($review);
 }
開發者ID:origammi,項目名稱:Sylius,代碼行數:7,代碼來源:Product.php

示例13: removeSetting

 /**
  * Remove setting.
  *
  * @param RoleSettingInterface $setting
  */
 public function removeSetting(RoleSettingInterface $setting)
 {
     $this->settings->remove($setting->getKey());
 }
開發者ID:sulu,項目名稱:sulu,代碼行數:9,代碼來源:Role.php

示例14: removeThirdParty

 /**
  * @param ThirdParty $thirdParty
  *
  * @return bool
  */
 public function removeThirdParty(ThirdParty $thirdParty)
 {
     return (bool) $this->thirdPartyCredentials->remove($thirdParty);
 }
開發者ID:stefanotorresi,項目名稱:thorr-oauth2,代碼行數:9,代碼來源:ThirdPartyAwareTrait.php

示例15: removeLesson

 /**
  * @param Lesson $lesson
  */
 public function removeLesson(Lesson $lesson)
 {
     $this->lessons->remove($lesson);
 }
開發者ID:uirapuru,項目名稱:evento,代碼行數:7,代碼來源:Workshop.php


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