[TYPO3-mvc] delete all related objects

Frans van der Veen[netcreators] frans at netcreators.com
Thu May 26 14:39:09 CEST 2011


On 05/20/2011 02:15 AM, Franz Koch wrote:
> If you only want to remove all "anhaenge" objects from the
> parent object, simply replace the objectStorage holding the related
> objects with a empty objectStorage.
>
> $foo->setAnhaenge(new Tx_Extbase_Persistence_ObjectStorage());

Can it be that this is not working in Extbase 1.3? I'm currently 
experiencing problems when doing it this way.

I'm trying to remove all the relations which my domain model has with 
another model.
The relation has been declared lazy.
When doing it as described above, it doesn't work. The existing 
relations remain.

When stepping through the code I notice that in
Tx_Extbase_Persistence_Backend::persistObject the objects in the related 
objectstorage aren't checked, since the dirty flag isn't set when 
replacing the object storage.

(from line 379):
			if ($propertyValue instanceof Tx_Extbase_Persistence_ObjectStorage) {
				if ($object->_isNew() || $propertyValue->_isDirty()) {
					$this->persistObjectStorage($propertyValue, $object, $propertyName, 
$row);
				}

When I do it as described above, add a dummy object and remove it 
directly afterwards again, however it does work (all relations gone). 
Which confirms my theory of the dirty flag not being set.

Any ideas?

Regards,

Frans


More information about the TYPO3-project-typo3v4mvc mailing list