覆盖管理模块中的executeIndex
在 symfony 生成的管理中,如何重写方法executeIndex()?
我只想列出具有特定状态的项目,而我在cache/backend/dev/modules/auto.../ 中找到的所有内容是:
$this->pager = $this->getPager();
如何更改寻呼机使用的查询?
In the administration generated by symfony, how do I override the method executeIndex() ?
I want to list only the items that have a specific state, and all I found in cache/backend/dev/modules/auto.../ was :
$this->pager = $this->getPager();
How do I change the query used by the pager ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
与重写现有类中的任何其他方法相同,例如表单中的
configure()
。打开 apps/yourapp/yourmodule/actions/actions.class.php 并添加:您可能会发现在缓存中查找自动生成的版本并从中复制所需的部分是个好主意在开始调整之前,进入您覆盖的方法 - 这为您提供了一个开始的工作基础。
The same way as you would override any other methods in existing classes eg
configure()
in a form. Open upapps/yourapp/yourmodule/actions/actions.class.php
and add:You might find it a good idea to look in your cache for the auto generated version, and copy the required parts from that into your overridden method, before you start adjusting - this gives you a working base to start from.
与马努所说的类似。但我建议你不要使用 getPager 而不是executeIndex。好一点......但本质上与马努的答案相同。
Similar to what manu says. But I would suggest you over ride getPager rather than executeIndex. Bit nicer ... but does essentially the same as manu's answer.
无需仅仅为了过滤结果而覆盖操作或模板。
最好在generator.yml中使用table_method选项
请参阅http://www.symfony-project.org/jobeet/ 1_4/Doctrine/en/12#chapter_12_sub_table_method
There's no need to ovveride action or templates just to filter your results.
It's better to use table_method option in generator.yml
See http://www.symfony-project.org/jobeet/1_4/Doctrine/en/12#chapter_12_sub_table_method