简体   繁体   English

Zend Framework 2-重定向器动作助手

[英]Zend Framework 2 - Redirector action helper

I've googled for quite a while but couldn't come up with a working solution for my problem. 我已经搜索了很长时间,但是无法为我的问题找到可行的解决方案。

When going to my website the user sees a login screen. 当访问我的网站时,用户会看到一个登录屏幕。 My ZFCUser forwards the user to my Application/index action. 我的ZFCUser将用户转发到我的“应用程序/索引”操作。 From there I want a "junction" which redirects regular users to one action and backend/admin users to another. 从那里,我想要一个“连接”,它将普通用户重定向到一个操作,将后端/管理员用户重定向到另一个操作。

In ZF1 it seems that there were this Redirector helper...? 在ZF1中,似乎有此Redirector帮助程序...?

Does anybody know a way to achieve what I want to do? 有人知道实现我想要做的事情的方法吗? Or maybe tell me a more Zend-y way of doing this? 还是告诉我一种更有效的方法? :) :)

Thanks! 谢谢!

You can use the redirect controller plugin in your action like this: 您可以在操作中使用重定向控制器插件,如下所示:

return $this->redirect()->toRoute('user-page');

user-page is the key of a defined route 用户页面是已定义路由的关键

OR 要么

return $this->getController()->redirect()->toUrl("http://www.mysite.com");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM