Zend Framework:使用Layout时在postDispath中获取输出

时间:2022-10-10 12:15:04

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?

如何将整个输出,布局和操作组合在一起?

Thanks!

谢谢!

1 个解决方案

#1


1  

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_Layout在具有高堆栈索引的postDispatch()上运行。因此,要获取内容,您可能需要稍后在dispatchLoopShutdown()处进行访问。

#1


1  

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_Layout在具有高堆栈索引的postDispatch()上运行。因此,要获取内容,您可能需要稍后在dispatchLoopShutdown()处进行访问。