Use the new detach helper in other batch delete use cases

[MAILPOET-5745]
This commit is contained in:
Jan Jakes
2023-11-29 14:56:39 +01:00
committed by Aschepikov
parent 45f5803293
commit 469bdebf9c
2 changed files with 13 additions and 1 deletions

View File

@@ -96,10 +96,17 @@ class FormsRepository extends Repository {
return 0;
}
return $this->entityManager->createQueryBuilder()
$result = $this->entityManager->createQueryBuilder()
->delete(FormEntity::class, 'f')
->where('f.id IN (:ids)')
->setParameter('ids', $ids)
->getQuery()->execute();
// delete was done via DQL, make sure the entities are also detached from the entity manager
$this->detachAll(function (FormEntity $entity) use ($ids) {
return in_array($entity->getId(), $ids, true);
});
return $result;
}
}