The doctrine mechanism of post/pre-delete is not working when deleting objects stored in a n:m relation tables. But pre/post-insert does work (so it has to be a bug).
For example, we've got two tables: product and category and product_category linking them in an n:m relation. In an admin module, there's category_list widget for each product. Inside BaseProductForm?, there is a public function saveCategoriesList($con = null) method with the following code:
$unlink = array_diff($existing, $values);
if (count($unlink))
{
$this->object->unlink('Categories', array_values($unlink));
}
$link = array_diff($values, $existing);
if (count($link))
{
$this->object->link('Categories', array_values($link));
}
CategoryProduct? has both postInsert defined, it is called,as it should be. It has also postDelete defined (and preDelete, just to test) and none of them is calles, when CategoryProduct? objects is deleted.
To sum up - $this->object->link seems to work fine and call postInsert on n:m relation objects, but $this->object->unlink seems to be buggy and doesn't call neither postDelete nor preDelete.