Skip to content

Commit

Permalink
Don't overwrite the response body if a controller returns an empty va…
Browse files Browse the repository at this point in the history
…lue.
  • Loading branch information
martywallace committed Jan 6, 2017
1 parent 05d9da8 commit 139cdd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "martywallace/tempest",
"version": "3.0.0",
"version": "3.0.1",
"description": "A tiny PHP framework.",
"homepage": "https://github.com/MartyWallace/Tempest",
"type": "library",
Expand Down
7 changes: 6 additions & 1 deletion src/Tempest/Http/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ public function dispatch() {
}

if ($respond) {
$this->_response->body = $this->instantiateAndCall($this->baseControllerNamespace . ltrim($this->_matched->controller, '\\'), $this->_request, $this->_response);
$controllerValue = $this->instantiateAndCall($this->baseControllerNamespace . ltrim($this->_matched->controller, '\\'), $this->_request, $this->_response);

if (!empty($controllerValue)) {
// If the controller returns a non-empty value, overwrite the response body with that value.
$this->_response->body = $controllerValue;
}
}
}

Expand Down

0 comments on commit 139cdd6

Please sign in to comment.