Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Softdeletable behaviour and really deleting the entity

I'm using DoctrineExtensions with StofDoctrineExtensionsBundle to get the soft-deleteable behaviour.

It works really well in the frontend of my application.

In the backend i need the option to "hard" delete entities.

I have disabled the filter in my admin controllers (i use SonataAdmin):

$filters = $this->getModelManager()->getEntityManager($this->getClass())->getFilters();

if (array_key_exists('softdeleteable', $filters->getEnabledFilters())) {
    $filters->disable('softdeleteable');
}

This works (soft deleted entities show up in the lists), but when i try to delete it, the entity does get soft-deleted again. How can i force a "hard" delete?

like image 702
smoove Avatar asked Nov 26 '12 18:11

smoove


1 Answers

Not the most graceful way : you always can do a real delete with SQL, it will bypass softdeletable

$em->createQuery("DELETE MyEntity e WHERE e = :et")->setParameter('et',$entity)->execute();
like image 57
Xmanoux Avatar answered Oct 23 '22 15:10

Xmanoux