最近,我一直在为我的后端接口探索Symfony的sfDoctrineGenerator。 问题是这样的:
我正在使用sfDoctrineGuardPlugin进行用户管理。 sfGuardUser 模块使用 sfDoctrineGenerator。 所有需要的功能(删除、编辑、添加)都在工作。目前为止,一切都好。
然后,我使用此链接作为参考创建了一个新模块。 添加和编辑功能现在可以工作,但我无法使删除(批量和单个删除)工作。 我尝试在批处理操作下显式添加它,但它仍然不起作用。它说它已经删除了显示闪存消息成功,但没有删除任何元素。 有人可以指出问题可能起源的正确方向吗?
这是我的生成器的副本.yml
generator:
class: sfDoctrineGenerator
param:
model_class: News
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: news
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
fields:
news: {label: Announcement}
created_at: {label: Date Published}
updated_at: {label: Date Updated}
user_id: {label: Author}
user_name: {label: Author}
list:
title: Announcements List
display: [=title, created_at, updated_at, user_name]
sort: [created_at, desc]
max_per_page: 10
batch_actions:
_delete: ~
filter:
display: [title, user_id]
form:
class: NewsForm
edit:
title: Editing Announcement "%%title%%"
new:
title: New Announcement
如果您需要我提供其他内容,请随时发表评论。 任何帮助将不胜感激。 提前谢谢。
更新:
以下是在 Chrome 中查看的请求标头:
Request URL:http://localhost:8080/inventory_dev.php/news
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ja_purity_tpl=ja_purity; fontSize=100; __atuvc=312|19; JSESSIONID=9DDD204812F0C53A8B3D33B89BF7A7C8; matciis=ha6l8ci8h3i2bp696e4h33vig2; symfony=ld2qept3j5cddjsb16qie098u3
Host:localhost:8080
Referer:http://localhost:8080/inventory_dev.php/news
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
Response Headersview source
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:text/html; charset=utf-8
Date:Wed, 30 May 2012 08:30:02 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=99
Pragma:no-cache
Server:Apache/2.2.21 (Win32) PHP/5.3.8
Transfer-Encoding:chunked
X-Powered-By:PHP/5.3.8
这是生活中的D'OH时刻之一。
问题是在我的 schema.yml 中,我指定了:
actAs: { Timestampable: ~ , SoftDelete: ~ }
这意味着当我删除元素时,它只会向其添加时间戳,而不是物理删除它。 我从配置中删除了软删除,问题已修复。
也许sfDoctrineGenerator中应该有一个功能来支持SoftDelete?