Disable view renderer and layout within controllers
1 2 3 4 56 7 8 9 1011 | <?php class MyController extends Zend_Controller_Action { public function indexAction() { $this->getHelper('layout')->disableLayout(); $this->getHelper('viewRenderer')->setNoRender(); } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
How to stop the automatic view and layout rendering within your controller actions.
Snippet details
- Created:
-
davedevelopment
- Edited:
-
davedevelopment
- Revision Id:
- 2
- Edit Message:
- Initial Release
- Tags:
- action helper view renderer controller
- Comments:
- 1
- Views:
- 383
- Points:
- 0 (0 votes)
1 year ago
I'd recommend checking if the Layout helper is defined before disabling the layout:
<pre>
if ($this->_helper->hasHelper('Layout')) {
$this->_helper->layout->disableLayout();
}
</pre>
That way you avoid producing errors when using PHPUnit.