symfony 1.4使用对象路由参数重定向到操作

时间:2013-11-06 13:40:35

标签: symfony-1.4

我无法将对象(或路由对象)从操作重定向到另一个操作。

我的行动档案:

protected function example(...){
  ...
  $object = Doctrine::getTable('object')->findOneById(1); //for example
  ...
  //dunno how to pass $object to executeShow 
  $url = $this->generateUrl('object_show', array('sf_subject' => $object));
  $this->redirect($url);

public function executeShow(sfWebRequest $request){
  $this->object = $this->getRoute()->getObject();
  ...
}

1 个答案:

答案 0 :(得分:2)

知道了:

protected function example(...){
  ...
  $object = Doctrine::getTable('object')->findOneById(1); //for example
  ...
  //this worked :)
  $this->getRequest()->setParameter('sf_subject', $object);
  $this->forward('module', 'show');
}
public function executeShow(sfWebRequest $request){
  $this->object = $this->getRoute()->getObject();
  ...
}