How to disable soft delete (Soft-deleteable) filter for doctrine in symfony

前端 未结 4 1671
梦如初夏
梦如初夏 2021-02-19 15:55

Installing and using SoftDeleteable behavior extension for Doctrine 2 is quite easy. The problem usually is trying to disable it for some code part and enabling again. You may w

4条回答
  •  粉色の甜心
    2021-02-19 16:32

    As in a former comment by qooplmao posted: A simple and working solution is:

    // Remove an entity entirely from the DB (skip soft delete)
    $this->entityManager->remove($entity);
    $this->entityManager->flush();
    // Just run it a second time :-)
    $this->entityManager->remove($entity);
    $this->entityManager->flush();
    

    Just posted it again to give it a little bot more visibility as it works like a charme...

提交回复
热议问题