hey Guys,
I'm hitting a little logic bump here. I want to store the contents of a view without outputting anything. I've managed to do it but i'm afraid of hitting bumps later on when someone uses this component outside of the normal context.
if(!is_null($viewName)) {
if(!$this->view) {
throw new Exception('No view engine registered!');
}
$mailView = clone $this->view;
$mailView->reset();
$mailView->setRenderLevel(View::LEVEL_NO_RENDER);
$mailView->setVar('bla', 'BLALALA');
$mailView->partial($viewName);
// get the contents from the outputBuffer when parsing the view
$this->_viewContent = ob_get_contents();
ob_end_clean();
}
This code works, but i don't feel comfortable with this solution. Does anybody have a better idea?