php – symfony:sfDoctrineRoute传递额外的参数
发布时间:2020-12-13 17:05:32 所属栏目:PHP教程 来源:网络整理
导读:我正在使用symfony 1.4,我的/ -Route有以下路由: homepage: url: / class: sfDoctrineRoute options: { model: ContentPage,type: object} param: { module: page,action: show} 而我的节目动作看起来像这样: class pageActions extends sfActions{ public
我正在使用symfony 1.4,我的/ -Route有以下路由:
homepage: url: / class: sfDoctrineRoute options: { model: ContentPage,type: object} param: { module: page,action: show} 而我的节目动作看起来像这样: class pageActions extends sfActions { public function executeShow(sfWebRequest $request) { $this->content_page = $this->getRoute()->getObject(); $this->forward404Unless($this->content_page); $this->forward404Unless($this->content_page->getPublished()); } } 它可以工作,但它总是选择ContentPage-Table的第一个条目. 问候, 解决方法
看看
sfDoctrineRoute的getObjectsForParameters()方法.
如您所见,您可以在路径定义中使用方法选项来定义将使用表模型的哪个方法来检索结果.您可以在此方法中添加条件. 第二种解决方案是使用method_for_query选项指定将使用表模型的哪个方法来修改查询并检索结果. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |