zend framework 2禁用整个应用程序的视图

时间:2013-01-08 08:48:53

标签: zend-framework2 zend-view

我目前正在Zend 2中开发后端应用程序,我需要禁用整个应用程序的视图。如果我能在初始阶段禁用它,我会非常高兴。这可能吗?

谢谢,

2 个答案:

答案 0 :(得分:0)

是的,这是可能的。在操作中使用以下代码隐藏视图。

return $this->getResponse();

答案 1 :(得分:0)

namespace YourModule;

use Zend\Mvc\MvcEvent;

class Module
{
    public function onBootstrap(MvcEvent $e)
    {
        $sharedEvents        = $e->getApplication()->getEventManager()->getSharedManager();
        $sharedEvents->attach('Zend\Mvc\Controller\AbstractActionController','dispatch', 
             function($e) {
                $response = $e->getResponse();
        $response->sendContent();
        });
    }
}