当前位置: 首页>>代码示例>>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;未经允许,请勿转载。