[TYPO3-dev] Extbase and removing M:N Relations in MM table

Miguel Ángel Molina Hernández miguel.molina at statistik.rlp.de
Wed Nov 30 17:15:06 CET 2016


Hello,

I'm developing extensions with extbase and fluid. I have some questions about how extbase works removing elements with MM-relations. I read a lot of post in forums about this topic, however I didn't reach to remove my relations in my MM-tables.

First, when I remove an object from my repository, $this->remove($object), I understand that extbase only change the column deleted to 1, and it doesn't mean the relations to this object have to be deleted. The option for this object to live again with deleted to 0 exists, and we want that the relations living on this way too. 

When does decideTypo3 when the relations have to be deleted?, or when does know Extbase the relations are not more necessary?, Who of both is the responsable of this decision?

I will explain one of my cases. I have a system for newsletter which works with categories. Two entities take place in this case, 'Email' and 'Category', the first one has an object storage from the second one. Category extends the Extbase category model and take another new properties for my cause. The relation is defined with an extra MM-table 'tx_myext_email_category_mm'.

When I remove an email object from my repository, the record get 1 in the column deleted, but the relations persist there, all rigth, the object can be there again and maybe I want his relations too there. But what when I remove the object from the trash? They are still there, and I can't delete those relations (in a clean way, without using directly sql or making a function for this job).

I tried with @cascade remove and the relation persist in the MM-Table. I can understand the idea, the trash is to restore the objects, but who does decide over the relations? When the objects are not more in the DB, their relations should not be neither there.

Do you have any idea how can I delete this relations? or how Typo3/Extbase do this?. Maybe I have errors on my code and for this reason, it doesn't work for me.

P.S.: Sorry for my english, I hope you understand my question.

Best regards



More information about the TYPO3-dev mailing list