Zend Framework:使用Layout时,在postDispath中获取整个输出 [英] Zend Framework: Get whole out output in postDispath while using Layout

查看:80
本文介绍了Zend Framework:使用Layout时,在postDispath中获取整个输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个布局加载器插件,如下所示:

I have a layout loader plugin which looks like this:

class Controller_Action_Helper_LayoutLoader extends Zend_Controller_Action_Helper_Abstract
{
    public function preDispatch()
    {
        $config = Zend_Registry::get("config");

        $module = $this->getRequest()->getModuleName();

        if (isset($config->$module->resources->layout->layout) && !$this->getRequest()->format)
        {
            $layoutScript = $config->$module->resources->layout->layout;
            $this->getActionController()->getHelper('layout')->setLayout($layoutScript);
        }
    }
}

然后在控制器插件中,我想像这样获得整个响应

In a controller plugin I then want to get the whole of the response like so

$this->getResponse()->getBody()

但是,这仅返回动作的输出,也不返回布局的输出.

This however only returns the output from the action, not the output from the layout too.

如何将整个输出,布局和动作放在一起?

How can I get the whole output, layout and action together?

谢谢!

推荐答案

我相信Zend_LayoutpostDispatch()上具有较高的堆栈索引.因此,要获取内容,您可能需要稍后在dispatchLoopShutdown()进行访问.

I believe that Zend_Layout operates at postDispatch() with a high stack index. So, to get the content, you might need to do your access later, at dispatchLoopShutdown().

这篇关于Zend Framework:使用Layout时,在postDispath中获取整个输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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