Now I am doing so:
public function indexAction() {
...
$view = new ViewModel(array(
'foo' => 'bar',
));
return $view;
}
The problem is that I want to do something after $view rendering and before layout rendering:
public function indexAction() {
...
$view = new ViewModel(array(
'foo' => 'bar',
));
$layout = $this->layout();
$layout->content = $view->render();
...
// here I want to do some important action
...
$html = $layout->render();
return $this->getResponse()->setContent($html);
}
But there is no method render(). In ZF1 I could render view:
$view = new Zend_View($data);
$html = $view->render($templateName);
How can I do that in ZF2?
Try this:
Complementing the answer, with layout included...