From 375e7fdcb4339badc9b5f9f000e36a59feced5c5 Mon Sep 17 00:00:00 2001 From: nan Date: Fri, 26 Feb 2016 18:38:57 +0100 Subject: [PATCH] Correction for Splash HtmlResponse toHtml repeated --- src/Mouf/Mvc/Splash/HtmlResponse.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Mouf/Mvc/Splash/HtmlResponse.php b/src/Mouf/Mvc/Splash/HtmlResponse.php index 6f2ec59..e0bddec 100644 --- a/src/Mouf/Mvc/Splash/HtmlResponse.php +++ b/src/Mouf/Mvc/Splash/HtmlResponse.php @@ -18,6 +18,11 @@ class HtmlResponse extends Response */ protected $htmlElement; + /** + * @var Stream + */ + protected $stream; + /** * Constructor. * @@ -67,12 +72,15 @@ public function getHtmlElement() */ public function getBody() { - ob_start(); - $this->htmlElement->toHtml(); - $content = ob_get_clean(); - $stream = new Stream('php://memory', 'wb+'); - $stream->write($content); + if ($this->stream === null) { + ob_start(); + $this->htmlElement->toHtml(); + $content = ob_get_clean(); + $this->stream = new Stream('php://memory', 'wb+'); + $this->stream->write($content); + + } - return $stream; + return $this->stream; } }