I want to temporarily disable softdelete, so I can find deleted entities by ID and then really delete them in my unit tests (so to make sure I do not clog the database).
What I tried:
$this->em->getFilters()->disable('softdeletable');
$item = $repository->findOneById($id); //fetch the item which was soft-deleted
$this->em->remove($item);
$this->em->flush();
But that throws an error:
InvalidArgumentException : Filter 'softdeletable' is not enabled.
I also tried disable('soft-deletable') and disable('soft-deleteable') etc - nothing worked. But when I look at $this->em->getFilters(), the filter is THERE:
["enabledFilters"]=>
array(1) {
["softdeletable"]=>
string(48) "Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter"
}
Trying the code without the disable of course doesn't work either:
Doctrine\ORM\ORMInvalidArgumentException : EntityManager#remove() expects parameter 1 to be an entity object, NULL given.
What am I doing wrong? I know I can really delete something with setting deletedAt to new DateTime but how do I delete an item without fetching it first?
Thanks for your help!