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


PHP ArrayCollection::remove方法代碼示例

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


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

示例1: toMany

 /**
  * @param mixed $valueOrObject
  * @param string $target
  * @return array
  */
 protected function toMany($valueOrObject, $target, Collection $collection = null, $depth = 2)
 {
     if (!is_array($valueOrObject) && !$valueOrObject instanceof Traversable) {
         $valueOrObject = (array) $valueOrObject;
     }
     if (!$collection instanceof Collection) {
         $collection = new ArrayCollection();
     }
     $keepers = array();
     foreach ($valueOrObject as $value) {
         if (method_exists($value, 'toArray')) {
             $value = $value->toArray($depth);
         } else {
             if (!is_array($value) && !$value instanceof Traversable) {
                 $value = (array) $value;
             }
         }
         if (isset($value['id']) && strlen($value['id']) && ($found = $this->find($target, $value['id']))) {
             $keepers[] = $found->id;
             $this->hydrate($value, $found);
         } else {
             $obj = new $target();
             $obj->fromArray($value);
             $obj->id = null;
             if ($collection instanceof PersistentCollection) {
                 if ($owner = $collection->getOwner()) {
                     $mapping = $collection->getMapping();
                     $mappedBy = $mapping['mappedBy'];
                     $obj->{$mappedBy} = $owner;
                 }
             }
             $collection->add($obj);
         }
     }
     $collection->forAll(function ($key, $element) use($collection, $keepers) {
         if (strlen($element->id) && !in_array($element->id, $keepers)) {
             $collection->remove($key);
         }
     });
     return $collection;
 }
開發者ID:MagmaDigitalLtd,項目名稱:ZucchiDoctrine,代碼行數:46,代碼來源:DoctrineEntity.php

示例2: remove

 /**
  * @param Car $car
  * @return boolean
  */
 public function remove(Car $car)
 {
     if (!$this->has($car)) {
         return false;
     }
     $this->cars->remove($car->getId());
     $this->session->set('cart', $this->cars);
     return true;
 }
開發者ID:s181150,項目名稱:my_project_name,代碼行數:13,代碼來源:Cart.php

示例3: removeMember

 /**
  * @param string $member
  * @return GroupOfNames
  */
 public function removeMember($member)
 {
     foreach ($this->members as $attr) {
         if ($attr->get() == $member) {
             $this->members->remove($attr);
             return $this;
         }
     }
     return $this;
 }
開發者ID:LenticularCloud,項目名稱:Cloud-Ldap-Admin,代碼行數:14,代碼來源:GroupOfNames.php

示例4: removeJoueurs

 /**
  * @param ArrayCollection $joueurs
  * @return Ligue $this
  */
 public function removeJoueurs($joueurs)
 {
     foreach ($joueurs as $joueur) {
         $this->joueurs->remove($joueur);
     }
     return $this;
 }
開發者ID:baptcomet,項目名稱:weprono,代碼行數:11,代碼來源:Ligue.php

示例5: removeChild

 /**
  * Removes child channel from collection
  *
  * @param CircularReferenceEntity $child child
  *
  * @return void
  */
 private function removeChild(CircularReferenceEntity $child)
 {
     $index = $this->getChildren()->indexOf($child);
     if ($index !== false) {
         $this->Children->remove($index);
     }
 }
開發者ID:RomanShumkov,項目名稱:EcentriaRestBundle,代碼行數:14,代碼來源:CircularReferenceEntity.php

示例6: remove

 public function remove($key)
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->remove($key);
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:7,代碼來源:AggregateEntryCollection.php

示例7: removeQuestion

 public function removeQuestion(SurveyQuestion $question)
 {
     if ($this->questions->contains($question)) {
         $this->questions->remove($question);
         $question->setSurvey(null);
     }
 }
開發者ID:scaytrase,項目名稱:symfony-survey-bundle,代碼行數:7,代碼來源:Survey.php

示例8: removeTaxonomy

 /**
  * @param TermTaxonomy $taxonomy
  *
  * @return Term
  */
 public function removeTaxonomy(TermTaxonomy $taxonomy)
 {
     if ($this->taxonomies->contains($taxonomy)) {
         $this->taxonomies->remove($taxonomy);
     }
     return $this;
 }
開發者ID:carboncreative,項目名稱:EkinoWordpressBundle,代碼行數:12,代碼來源:Term.php

示例9: remove

 /**
  * {@inheritdoc}
  */
 public function remove($key)
 {
     foreach ($this->fields as $managerName => $method) {
         call_user_func(array(self::getElementMethod($this->model, $managerName, $method), 'remove'), $key);
     }
     return parent::remove($key);
 }
開發者ID:pokap,項目名稱:pool-dbm,代碼行數:10,代碼來源:ArrayCollection.php

示例10: removeRelationship

 /**
  * @param TermRelationships $relationship
  *
  * @return Term
  */
 public function removeRelationship(TermRelationships $relationship)
 {
     if ($this->relationships->contains($relationship)) {
         $this->relationships->remove($relationship);
     }
     return $this;
 }
開發者ID:thedarsideofit,項目名稱:EkinoWordpressBundle,代碼行數:12,代碼來源:TermTaxonomy.php

示例11: removeReport

 public function removeReport(ReportModule $reportModule)
 {
     $index = $this->modules->indexOf($reportModule);
     if ($index !== null) {
         $this->modules->remove($index);
     }
     return $this;
 }
開發者ID:Quiss,項目名稱:RNMoT,代碼行數:8,代碼來源:Report.php

示例12: removeCourse

 public function removeCourse(CourseModule $courseModule)
 {
     $index = $this->modules->indexOf($courseModule);
     if ($index !== null) {
         $this->modules->remove($index);
     }
     return $this;
 }
開發者ID:Quiss,項目名稱:Learning,代碼行數:8,代碼來源:Course.php

示例13: remove

 /**
  * {@inheritdoc}
  */
 public function remove($key)
 {
     $removedElement = parent::remove($key);
     if (null !== $removedElement) {
         unset($this->keys[(string) $removedElement]);
     }
     return $removedElement;
 }
開發者ID:startupz,項目名稱:platform-1,代碼行數:11,代碼來源:PublicResourceCollection.php

示例14: setProcessed

 /**
  * @param $item
  * @param $key
  */
 protected function setProcessed(ImportItemProcess $item, $key)
 {
     $this->entityManager->remove($item);
     $this->itemProcessCollection->remove($key);
     $this->importLog->addProcessItemCount();
     $this->processedItemCount++;
     $index = $item->getItemIndex();
     $this->setItemLogIndex($index);
 }
開發者ID:jarold87,項目名稱:pingvin,代碼行數:13,代碼來源:ItemCollector.php

示例15: drop

 /**
  * Drops a Collection - removing all data
  *
  * @param  string $collection  The name of the Collection to drop
  */
 public function drop($collection)
 {
     if (!$this->collections->containsKey($collection)) {
         return false;
     }
     $this->collections->get($collection)->drop();
     $this->collections->remove($collection);
     return true;
 }
開發者ID:kmfk,項目名稱:slowdb,代碼行數:14,代碼來源:Database.php


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