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


PHP PersistentCollection::removeElement方法代码示例

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


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

示例1: removePost

 public function removePost(Post $post)
 {
     if (!$this->hasPost($post)) {
         throw new DomainException('Post is not exists');
     }
     $this->posts->removeElement($post);
 }
开发者ID:nebuchar,项目名称:ddd-blog,代码行数:7,代码来源:User.php

示例2: clearPreviousCollection

 /**
  * Resets previous photo collection
  *
  * @param PersistentCollection $collection
  */
 protected function clearPreviousCollection(PersistentCollection $collection)
 {
     if ($collection->count()) {
         foreach ($collection as $item) {
             $collection->removeElement($item);
         }
     }
 }
开发者ID:raizeta,项目名称:WellCommerce,代码行数:13,代码来源:ProductPhotoCollectionToArrayTransformer.php

示例3: postSetDataProvider

 /**
  * @return array
  */
 public function postSetDataProvider()
 {
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $meta = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $existing = (object) ['$existing' => true];
     $removed = (object) ['$removed' => true];
     $added = (object) ['$added' => true];
     $collectionWithElements = new ArrayCollection([$added]);
     $cleanCollection = new PersistentCollection($em, $meta, new ArrayCollection());
     $dirtyCollection = new PersistentCollection($em, $meta, new ArrayCollection([$existing, $removed]));
     $dirtyCollection->takeSnapshot();
     $dirtyCollection->removeElement($removed);
     $dirtyCollection->add($added);
     return ['Initialization with empty value should not be broken' => ['$data' => null, '$expectedAddedData' => [], '$expectedRemovedData' => []], 'Empty collection given should set nothing' => ['$data' => new ArrayCollection(), '$expectedAddedData' => [], '$expectedRemovedData' => []], 'Array collection with elements given, should be set to added' => ['$data' => $collectionWithElements, '$expectedAddedData' => [$added], '$expectedRemovedData' => []], 'Clean persistent collection given, should set nothing' => ['$data' => $cleanCollection, '$expectedAddedData' => [], '$expectedRemovedData' => []], 'Persistent collection given, should set from diffs' => ['$data' => $dirtyCollection, '$expectedAddedData' => [$added], '$expectedRemovedData' => [$removed]]];
 }
开发者ID:Maksold,项目名称:platform,代码行数:18,代码来源:MultipleEntitySubscriberTest.php

示例4: removePermissions

 public function removePermissions(Collection $permissions)
 {
     foreach ($permissions as $permission) {
         $this->permissions->removeElement($permission);
     }
 }
开发者ID:LeCoyote,项目名称:epeires2,代码行数:6,代码来源:Role.php

示例5: removeTournament

 /**
  * @param TournamentPlayer $player
  * @return User
  */
 public function removeTournament(TournamentPlayer $player) : User
 {
     $this->tournaments->removeElement($player);
     return $this;
 }
开发者ID:StasPiv,项目名称:playzone,代码行数:9,代码来源:User.php


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