在Symfony2中无损删除实体 [英] Deleting entities non-destructively in Symfony2

查看:66
本文介绍了在Symfony2中无损删除实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Symfony 2中,有没有一种好的,干净且简单的方法来无损地删除实体?我想给我的管理员一个取消删除项目的机会,同时尽可能减少框架提供的自动化.

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.

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

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?

推荐答案

您想要的是软删除.为此,有一个文档扩展和一个捆绑以将其与Symfony集成.

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

这篇关于在Symfony2中无损删除实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆