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


PHP Collection::removeElement方法代码示例

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


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

示例1: removeActivityPrototype

 /**
  * {@inheritdoc}
  */
 public function removeActivityPrototype(ActivityPrototypeInterface $activityPrototype)
 {
     if ($this->hasActivityPrototype($activityPrototype)) {
         $this->activityPrototypes->removeElement($activityPrototype);
     }
     return $this;
 }
开发者ID:upenn-dag,项目名称:patient-repository,代码行数:10,代码来源:Prototype.php

示例2: reverseTransform

 /**
  * @param array $ids
  * @param Collection $collection
  */
 public function reverseTransform($ids, $collection)
 {
     if (count($ids) == 0) {
         // don't check for collection count, a straight clear doesnt initialize the collection
         $collection->clear();
         return $collection;
     }
     $em = $this->getOption('em');
     $metadata = $em->getClassMetadata($this->getOption('className'));
     $reflField = $metadata->getReflectionProperty($metadata->identifier[0]);
     foreach ($collection as $object) {
         $key = array_search($reflField->getValue($object), $ids);
         if (false === $key) {
             $collection->removeElement($object);
         } else {
             unset($ids[$key]);
         }
     }
     // @todo: This can be greatly optimized into a single SELECT .. WHERE id IN () query.
     foreach ($ids as $id) {
         $entity = $em->find($this->getOption('className'), $id);
         if (!$entity) {
             throw new TransformationFailedException("Selected entity of type '" . $this->getOption('className') . "' by id '" . $id . "' which is not present in the database.");
         }
         $collection->add($entity);
     }
     return $collection;
 }
开发者ID:notbrain,项目名称:symfony,代码行数:32,代码来源:CollectionToChoiceTransformer.php

示例3: removePromotion

 /**
  * {@inheritdoc}
  */
 public function removePromotion(PromotionInterface $promotion)
 {
     if ($this->hasPromotion($promotion)) {
         $this->promotions->removeElement($promotion);
     }
     return $this;
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:10,代码来源:OrderItem.php

示例4: removeActivity

 /**
  * {@inheritdoc}
  */
 public function removeActivity(ActivityInterface $activity)
 {
     if ($this->hasActivity($activity)) {
         $this->activities->removeElement($activity);
         $activity->setRegimen(null);
     }
 }
开发者ID:upenn-dag,项目名称:patient-repository,代码行数:10,代码来源:Regimen.php

示例5: removeElement

 /**
  * {@inheritdoc}
  */
 public function removeElement($element) : bool
 {
     $return = parent::removeElement($element);
     if ($return) {
         $this->removeFromHistory($element);
     }
     return $return;
 }
开发者ID:cawaphp,项目名称:cawa,代码行数:11,代码来源:CollectionModel.php

示例6: removeChild

 /**
  * {@inheritdoc}
  */
 public function removeChild(PermissionInterface $permission)
 {
     if ($this->hasChild($permission)) {
         $permission->setParent(null);
         $this->children->removeElement($permission);
     }
     return $this;
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:11,代码来源:Permission.php

示例7: removeElement

 /**
  * {@inheritdoc}
  */
 public function removeElement($element)
 {
     $this->initialize();
     $removed = $this->coll->removeElement($element);
     if ($removed) {
         $this->changed();
         if ($this->mapping !== null && isset($this->mapping['embedded'])) {
             $this->uow->scheduleOrphanRemoval($element);
         }
     }
     return $removed;
 }
开发者ID:richardmiller,项目名称:mongodb-odm,代码行数:15,代码来源:PersistentCollection.php

示例8: hydrate

 /**
  * Adds or removes a social profile from the collection.
  *
  * @param array $data
  * @param Collection $object
  * @see \Zend\Hydrator\HydratorInterface::hydrate()
  * @return \Auth\Entity\SocialProfiles\ProfileInterface
  */
 public function hydrate(array $data, $object)
 {
     foreach ($data as $name => $value) {
         if (!isset($this->profileClassMap[$name])) {
             continue;
         }
         if (empty($value)) {
             // We need to check, if collection has a profile and
             // remove it.
             foreach ($object as $p) {
                 if ($p instanceof $this->profileClassMap[$name]) {
                     $object->removeElement($p);
                     continue 2;
                 }
             }
             // No profile found, so do nothing.
             continue;
         }
         if (is_string($value)) {
             $value = \Zend\Json\Json::decode($value, \Zend\Json\Json::TYPE_ARRAY);
         }
         /* If there is already a profile of this type, we do not need to
          * add it, but update the data only.
          */
         foreach ($object as $p) {
             if ($p instanceof $this->profileClassMap[$name]) {
                 // Already a profile in the collection, just update and continue main loop.
                 $p->setData($value);
                 continue 2;
             }
         }
         // We need to add a new profile to the collection.
         $class = $this->profileClassMap[$name];
         $profile = new $class();
         $profile->setData($value);
         $object->add($profile);
     }
     return $object;
 }
开发者ID:utrenkner,项目名称:YAWIK,代码行数:47,代码来源:SocialProfilesHydrator.php

示例9: removeProjectUser

 /**
  * Remove projectUser
  *
  * @param \CentraleLille\CustomFosUserBundle\Entity\ProjectUser $projectUser
  */
 public function removeProjectUser(\CentraleLille\CustomFosUserBundle\Entity\ProjectUser $projectUser)
 {
     $this->projectUsers->removeElement($projectUser);
 }
开发者ID:pierloui,项目名称:fablab,代码行数:9,代码来源:Project.php

示例10: removeFavoriteBundle

 /**
  * Remove favorite Bundle
  *
  * @param Bundle $favoriteBundle
  */
 public function removeFavoriteBundle(Bundle $favoriteBundle)
 {
     $this->favoriteBundles->removeElement($favoriteBundle);
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:9,代码来源:Developer.php

示例11: removeExam

 /**
  * 
  * @param Exam $exam
  * @return ExamContent
  */
 function removeExam($exam)
 {
     $this->exams->removeElement($exam);
     $exam->setContent(null);
     return $this;
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:11,代码来源:ExamContent.php

示例12: removeElement

 /**
  * {@inheritdoc}
  */
 public function removeElement($element)
 {
     // TODO: Assuming the identity of entities in a collection is always based
     //       on their primary key (there is no equals/hashCode in PHP),
     //       if the collection is not initialized, we could issue a straight
     //       SQL DELETE/UPDATE on the association (table) without initializing
     //       the collection.
     /*if ( ! $this->_initialized) {
           $this->_em->getUnitOfWork()->getCollectionPersister($this->_association)
               ->deleteRows($this, $element);
       }*/
     $this->_initialize();
     $result = $this->_coll->removeElement($element);
     $this->_changed();
     return $result;
 }
开发者ID:andreia,项目名称:doctrine,代码行数:19,代码来源:PersistentCollection.php

示例13: removeChild

 /**
  * 
  * @param Subject $child
  * @return Subject
  */
 function removeChild($child)
 {
     $this->children->removeElement($child);
     return $this;
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:10,代码来源:Subject.php

示例14: removeUser

 /**
  * Remove User entity from collection (one to many).
  *
  * @param \Entity\User $user
  * @return \Entity\Country
  */
 public function removeUser(User $user)
 {
     $this->users->removeElement($user);
     return $this;
 }
开发者ID:odegroot,项目名称:ers,代码行数:11,代码来源:Country.php

示例15: removeResponse

 /**
  *
  * @param \Amisure\P4SApiBundle\Entity\EvaluationModelItemResponse $item        	
  * @return \Amisure\P4SApiBundle\Entity\EvaluationModelItem
  */
 public function removeResponse(\Amisure\P4SApiBundle\Entity\EvaluationModelItemResponse $response)
 {
     $this->responses->removeElement($response);
     return $this;
 }
开发者ID:trialog,项目名称:p4s-api-bundle,代码行数:10,代码来源:EvaluationModelItem.php


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