Pdf: Restore previous state after rendering content
In case an exception occurs its output was previously merged with the rendered content or even PDF..
This commit is contained in:
parent
c12da7b7ac
commit
5943e6bde9
|
@ -51,14 +51,19 @@ class Pdf
|
||||||
Environment::raiseExecutionTime(300);
|
Environment::raiseExecutionTime(300);
|
||||||
|
|
||||||
$viewRenderer = $controller->getHelper('viewRenderer');
|
$viewRenderer = $controller->getHelper('viewRenderer');
|
||||||
$controller->render(
|
$viewRenderer->postDispatch();
|
||||||
$viewRenderer->getScriptAction(),
|
|
||||||
$viewRenderer->getResponseSegment(),
|
$layoutHelper = $controller->getHelper('layout');
|
||||||
$viewRenderer->getNoController()
|
$oldLayout = $layoutHelper->getLayout();
|
||||||
);
|
$layout = $layoutHelper->setLayout('pdf');
|
||||||
$layout = $controller->getHelper('layout')->setLayout('pdf');
|
|
||||||
$layout->content = $controller->getResponse();
|
$layout->content = $controller->getResponse();
|
||||||
$html = $layout->render();
|
$html = $layout->render();
|
||||||
|
|
||||||
|
// Restore previous layout and reset content, to properly show errors
|
||||||
|
$controller->getResponse()->clearBody($viewRenderer->getResponseSegment());
|
||||||
|
$layoutHelper->setLayout($oldLayout);
|
||||||
|
|
||||||
$imgDir = Url::fromPath('img');
|
$imgDir = Url::fromPath('img');
|
||||||
$html = preg_replace(
|
$html = preg_replace(
|
||||||
'~src="' . $imgDir . '/~',
|
'~src="' . $imgDir . '/~',
|
||||||
|
|
|
@ -484,8 +484,8 @@ class ActionController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($req->getParam('format') === 'pdf') {
|
if ($req->getParam('format') === 'pdf') {
|
||||||
$this->shutdownSession();
|
|
||||||
$this->sendAsPdf();
|
$this->sendAsPdf();
|
||||||
|
$this->shutdownSession();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue