ZF2在重定向时不使用参数

时间:2013-09-10 12:35:38

标签: php routes zend-framework2

我的应用程序中存在路由问题。

$this->redirect('someone', array('controller' => 'account', 'action' => 'settings'));

它总是重定向到app.dev/someone与数组中的内容无关。

我发现问题出在 TreeRouteStack.php

汇编方法中

TreeRouteStack.php:347

$path = $this->baseUrl . $route->assemble(array_merge($this->defaultParams, $params), $options);

我在这行之前试过“死”来测试$ params - 一切都好。因此,在上方的代码之前die(implode(',',$params));返回

  

帐户,设置

但在此echo $path 返回

之后
  

/有人

而不是

  

/有人/帐户/设置

哪里可能有问题?我正在使用ZF2 2.2.2

1 个答案:

答案 0 :(得分:1)

使用

$this->redirect()->toRoute(
    'someone',
     array('controller' => 'account', 'action' => 'settings')
); 

而不是

$this->redirect(
    'someone',
    array('controller' => 'account', 'action' => 'settings')
);

请查看zf2文档中的Redirect Plugin