Example #1
0
 public function removePost(Post $post)
 {
     if (!$this->hasPost($post)) {
         throw new DomainException('Post is not exists');
     }
     $this->posts->removeElement($post);
 }
 /**
  * Resets previous photo collection
  *
  * @param PersistentCollection $collection
  */
 protected function clearPreviousCollection(PersistentCollection $collection)
 {
     if ($collection->count()) {
         foreach ($collection as $item) {
             $collection->removeElement($item);
         }
     }
 }
 /**
  * @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]]];
 }
Example #4
0
 public function removePermissions(Collection $permissions)
 {
     foreach ($permissions as $permission) {
         $this->permissions->removeElement($permission);
     }
 }
Example #5
0
 /**
  * @param TournamentPlayer $player
  * @return User
  */
 public function removeTournament(TournamentPlayer $player) : User
 {
     $this->tournaments->removeElement($player);
     return $this;
 }