Skip to content

Commit 303dc01

Browse files
committed
Merge pull request #20 from charles4201/7.0
Correction for Splash HtmlResponse toHtml repeated
2 parents 89577a4 + 375e7fd commit 303dc01

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Mouf/Mvc/Splash/HtmlResponse.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class HtmlResponse extends Response
1818
*/
1919
protected $htmlElement;
2020

21+
/**
22+
* @var Stream
23+
*/
24+
protected $stream;
25+
2126
/**
2227
* Constructor.
2328
*
@@ -67,12 +72,15 @@ public function getHtmlElement()
6772
*/
6873
public function getBody()
6974
{
70-
ob_start();
71-
$this->htmlElement->toHtml();
72-
$content = ob_get_clean();
73-
$stream = new Stream('php://memory', 'wb+');
74-
$stream->write($content);
75+
if ($this->stream === null) {
76+
ob_start();
77+
$this->htmlElement->toHtml();
78+
$content = ob_get_clean();
79+
$this->stream = new Stream('php://memory', 'wb+');
80+
$this->stream->write($content);
81+
82+
}
7583

76-
return $stream;
84+
return $this->stream;
7785
}
7886
}

0 commit comments

Comments
 (0)