[TYPO3-mvc] Problems with clearing an ObjectStorage

Sebastian Michaelsen sebastian.gebhard at gmail.com
Wed Jun 22 17:06:17 CEST 2011


Hi *,

i'm having a hard time with quite a simple problem. I just missed 
something basic or misunderstood something..


I want to empty an Tx_Extbase_Persistence_ObjectStorage, because an 
object with an n:m property should lose all its relations.

Why can't I just call removeAll() on an ObjectStorage? The method 
exists, but it requires another ObjectStorage as an argument (the group 
of objects to be removed).

I tried:


/**
  * @var Tx_Extbase_Persistence_ObjectStorage<Tx_Myext_Domain_Model_Foo> 
$favorites
  */
protected $favorites;

public function removeAllFavorites() {
	$this->getFavorites()->removeAll($this->getFavorites());
}

But the ObjectStorage ($this->favorites) is not empty afterwards. It 
clears out almost all objects, except 1. One object is always left and I 
don't know why.

Any hints?

Kind regards and thanks for any help,
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list