Zend Framework,$ this-> _forward在做什么 [英] Zend Framework, what $this->_forward is doing

查看:75
本文介绍了Zend Framework,$ this-> _forward在做什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人向我解释_forward到底在做什么,我看不出_forward是否也在将附加视图呈现给操作或只是执行操作.

I would like someone to explain me what _forward is exactly doing, I cannot see if _forward is also rendering the attached view to the action or just executing the action.

还可以在视图脚本中将参数传递给$ this-> action吗?

Also is it possible to pass argument to $this->action in a view script ?

更一般而言,我的问题是如何编写确认页面代码,假设用户输入了一些内容,而您想向他显示确认信息,那么对于这种情况,转发意味着什么?

More generally my problem is how to code a confirmation page, let's say the user input some stuff and you want to show him confirmation, is forward is mean for that case ?

推荐答案

_forward是内部重定向. _redirect发送一个标头告诉客户端的浏览器转到其他URL,而_forward告诉分派器在内部将请求重定向到其他地方.

_forward is an internal redirect. Where as _redirect sends a header that tells the client's browser to go to some other URL, _forward tells the Dispatcher to internally redirect the request somewhere else.

如果考虑以下正常的发送顺序:

If you consider the normal dispatch order of:

 preDispatch()
 someAction()
 postDispatch()

在进度中的任何时候调用_forward都将导致以下步骤无法执行.因此,如果在preDispatch()中调用_forward,将不会调用someAction(),依此类推.如果您在someAction()中使用_forward()并使用viewRenderer动作帮助器来呈现视图(让框架选择要呈现的视图脚本),那么在someAction()中将不会呈现任何视图脚本.

Calling _forward at any point in that progression will cause the following steps to not be executed. So if you call _forward in preDispatch(), someAction() will not be called and so on. If you _forward() in someAction() and you are using the viewRenderer action helper to render your views (you are letting the framework choose what view script to render), then no view script will be rendered in someAction().

当请求转发到新的控制器/模块时,整个调度过程将在此重复.

When the request is forwarded to the new Controller / Module the entire dispatch process will be repeated there.

您可以使用以下命令找出要分派的动作:

You can find out what action is being dispatched by using:

 $action = $this->getRequest()->getParam('action');

$ action将是操作的url形式,因此,如果方法名为"someKindOfAction",则$ action将包含"some-kind-of".您也可以对控制器和模块执行此操作.

$action will be the url form of the action so if the method is name 'someKindOfAction', $action will contain 'some-kind-of'. You can do this as well for controllers and modules.

这篇关于Zend Framework,$ this-> _forward在做什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆