我希望有人向我解释 _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 则告诉 Dispatcher 在内部将请求重定向到其他地方.
_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 框架,$this->_forward 在做什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!