在Symfony2中非破坏性地删除实体

时间:2022-10-24 06:45:54

Is there a good, clean and simple way to delete entities non-destructively in Symfony 2? I'd like to give my administrators a chance to undelete items, while sacrificing as little of the automation provided by the framework as possible.

在Symfony 2中是否有一种非常好,干净且简单的方法来非破坏性地删除实体?我想让我的管理员有机会取消删除项目,同时尽可能少地牺牲框架提供的自动化。

If there is no built-in solution or third party bundle to help me, what would be the best way to do this? Adding a deleted property to entities would require lots of added logic to keep them from cluttering the controllers created by doctrine:generate:crud, so maybe they should be stored in a separate table in serialized form?

如果没有内置解决方案或第三方软件包来帮助我,那么最好的方法是什么?将删除的属性添加到实体将需要大量添加的逻辑,以防止它们混乱由doctrine:generate:crud创建的控制器,所以它们可能应该以序列化形式存储在单独的表中?

1 个解决方案

#1


14  

What you want is Soft Delete. There is a Doctrine extension for that and a bundle to integrate it with Symfony.

你想要的是软删除。有一个Doctrine扩展,以及一个将它与Symfony集成的包。

#1


14  

What you want is Soft Delete. There is a Doctrine extension for that and a bundle to integrate it with Symfony.

你想要的是软删除。有一个Doctrine扩展,以及一个将它与Symfony集成的包。