Skip to content

Commit a387bbe

Browse files
committed
Merge branch '7.0' of git://github.com/thecodingmachine/mvc.splash-common into 7.0
2 parents 2d7cf3d + 303dc01 commit a387bbe

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/Mouf/Mvc/Splash/Controllers/Controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ public function getUrlsList($instanceName)
9494
if ($refMethod->hasAnnotation('Action')) {
9595
$methodName = $refMethod->getName();
9696
if ($methodName == 'index' || $methodName == 'defaultAction') {
97-
$url = $moufManager->findInstanceName($this).'/';
97+
$url = $instanceName.'/';
9898
} else {
99-
$url = $moufManager->findInstanceName($this).'/'.$methodName;
99+
$url = $instanceName.'/'.$methodName;
100100
}
101101
$parameters = SplashUtils::mapParameters($refMethod);
102102
$filters = FilterUtils::getFilters($refMethod, $this);
103-
$urlsList[] = new SplashRoute($url, $moufManager->findInstanceName($this), $refMethod->getName(), $title, $refMethod->getDocCommentWithoutAnnotations(), $refMethod->getDocComment(), $this->getSupportedHttpMethods($refMethod), $parameters, $filters);
103+
$urlsList[] = new SplashRoute($url, $instanceName, $refMethod->getName(), $title, $refMethod->getDocCommentWithoutAnnotations(), $refMethod->getDocComment(), $this->getSupportedHttpMethods($refMethod), $parameters, $filters);
104104
}
105105

106106
// Now, let's check the "URL" annotation (note: we support multiple URL annotations for the same method)

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
}

src/Mouf/Mvc/Splash/Services/SplashUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static function buildControllerResponse($callback, $mode = self::MODE_STR
146146
}
147147
$html = ob_get_clean();
148148

149-
if (!empty($html)) {
149+
if (!empty($html) || $mode === self::MODE_WEAK) {
150150
if ($mode === self::MODE_WEAK) {
151151
$code = http_response_code();
152152
$headers = self::getResponseHeaders();

0 commit comments

Comments
 (0)