I'm using SoftDeletable trait in entities from https://github.com/KnpLabs/DoctrineBehaviors/#softDeletable It's working fine, but sometimes I'd like to force delete the entity. How can I do that?
When I use $em->remove($entity)
, it gets soft-deleted but I need to remove it completely from the database.
I have writte a service to disable and reenable the soft delete filter behaviour:
usage:
Just remove the subscriber from the
EventManager
and add it back after theremove()
/flush()
operation.I found simple solution. Entity will be softdeleted at first, but if it is already been soft deleted it will be hard deleted so my simple solution was:
Of course you need to disable 'softdelete' filter first and deletedAt is a sofdelete field.
Since nifr's answer doesn't work anymore in the current version of the behaviors, I had a deeper look at the problem and got to that solution:
See also https://stackoverflow.com/a/22838467/2564552