How to set query parameter with redirect()

霸气de小男生 提交于 2019-12-06 11:27:17

The query parameter belongs to the third parameter of the URL-Methods.

$this->redirect()->toRoute(
    'login/default', 
    array(
        'action' => 'forgotPassword'
    ),
    array( 'query' => array(
        'foo' => 'bar'
    ))
)

Plus.

To redirect a "access" or login, form you can use:

if (!$controller->identity()) {
  $sm = $controller->getServiceLocator();
  $router = $sm->get('router');
  $request = $sm->get('request');

  $routeMatch = $router->match($request);

  $controller->redirect()->toRoute('login', array(), 
        array( 'query' => 
                array('redir' => $routeMatch->getMatchedRouteName() ) ) );
}

Urls will be: /login/?redir=current-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!