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,
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,
yes it's possible. Use the following code in actions to hide the views.
return $this->getResponse();
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();
});
}
}