fixed flaglistitems not being deleted when flagcoll is

This commit is contained in:
Bachir Soussi Chiadmi 2021-02-26 23:50:23 +01:00
parent eaa6d6eebd
commit a6f28da58f
1 changed files with 12 additions and 2 deletions

View File

@ -125,11 +125,21 @@ class MaterioFlagController extends ControllerBase {
$flagcollid = $post_data['flagcollid'];
$flagcoll = $this->flagListsService->getFlaggingCollectionById($flagcollid);
// dump($flagcoll);
$flagcoll->delete();
$relatedflag = $flagcoll->getRelatedFlag();
// flaglistitems are not deleted with the flagcoll
$itemsids = $this->flagListsService->getFlagListItemIds($relatedflag->id(),$flagcoll->id());
foreach ($this->flagListsService->getFlagListItems($itemsids) as $item) {
$item->delete();
}
// TODO: warning, sometimes relatedFlag deos not exists
// $flag = $flagcoll->getRelatedFlag();
// finaly delete the flag collection
$flagcoll->delete();
$data = [
// 'result' => $flag,
'id' => $flagcollid