0

I'm currently developing the back-end application in Zend 2 and I need to disable view for entire application. I'll be more than happy if I can disable it on init stage. Is this possible?

Thanks,

siuda
  • 33
  • 5
  • Why don't you just leave your view scripts empty? Do you need to be able to disable all views for certain requests? Or for all requests? – kokx Jan 08 '13 at 09:22

2 Answers2

0

yes it's possible. Use the following code in actions to hide the views.

return $this->getResponse();
2plus
  • 261
  • 1
  • 7
  • 16
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();
        });
    }
}
samsonasik
  • 440
  • 1
  • 6
  • 11