我想在渲染布局之前执行一些代码,然后执行所有其他代码.我会把那个代码放在哪里?
我特别想在布局使用 headLink、headScript 和 inlineScript 视图助手中引用的文件之前对其进行修改.
以下是我要采取的步骤:
<小时>
前端控制器插件似乎不会帮助我实现这一点,原因如下:
postDispatch()
在执行每个控制器操作后执行,我需要样式表/javascripts 的完整列表dispatchLoopShutdown()
在控制器动作循环后执行,但此时布局已经呈现<小时>
正如 Rufinus 所建议的,我通过扩展视图助手解决了这个问题.(镜像)
您可以通过插件访问的最后一部分应该是 dispatchLoopShutdown
ZendFramework2 参见 http://zendframework2.de/en/cheat-sheet.html或 这个 gdoc
I want to execute some code right before the layout is rendered, after all other code is executed. Where would I put that code?
I am specifically trying to modify the files referenced in the headLink, headScript, and inlineScript view helpers before they're used by the layout.
Here are the steps I want to take:
It doesn't appear that a Front Controller Plugin is going to help me accomplish this, and here's why:
postDispatch()
gets executed after every controller action that's executed, and I need the full list of stylesheets/javascriptsdispatchLoopShutdown()
gets executed after the controller action loop, but the layout has already been rendered at this point
As Rufinus suggested, I solved this by extending the View Helpers. My question from that angle as well as the solution is here.
see Orginal PDF created by Thorsten Ruf (Mirror)
the very last part you can access via plugin should be dispatchLoopShutdown
EDIT: For ZendFramework2 see http://zendframework2.de/en/cheat-sheet.html or this gdoc
这篇关于Zend 框架 - 在呈现布局之前执行的最后一段代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!