Zend Framework: Get whole out output in postDispath while using Layout

旧时模样 提交于 2019-12-14 03:07:51

问题


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:


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().



来源:https://stackoverflow.com/questions/4581271/zend-framework-get-whole-out-output-in-postdispath-while-using-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!