0
怎樣的sfDoctrineRoute類的工作symfony的sfDoctrineRoute模型問題
例如我不能完全理解,我有以下途徑:
Comment:
class: sfDoctrineRouteCollection
options:
prefix_path: :username/comment
module: comment
model: Comment
現在
,在commentActions
類executeNew()
方法,該代碼:
$this->getRoute()->getObject()
將返回我的數據庫中的第一個Comment對象。當然我可以手動創建一個new Comment()
對象,但是使用sfDoctrineRoute
類代替sfRoute
有什麼好處?
例如,如果您決定切換到基於slug的url,添加到專業人員列表中,您只需更改一些路由選項,而不是在所有操作中更改代碼。 – Dziamid 2011-06-03 08:25:56
@dziamid另一個好點,ta – benlumley 2011-06-03 13:42:30
是的,你對..非常感謝! :)順便說一句,有沒有辦法阻止它從我的數據庫中取出executeNew的任何記錄? – tamir 2011-06-04 19:24:37