From 139cdd60aa3ce7222e1f4405ec56221600ac4335 Mon Sep 17 00:00:00 2001 From: Marty Wallace Date: Sat, 7 Jan 2017 10:37:01 +1100 Subject: [PATCH] Don't overwrite the response body if a controller returns an empty value. --- composer.json | 2 +- src/Tempest/Http/Router.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9d0a3a2..b03439c 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Tempest/Http/Router.php b/src/Tempest/Http/Router.php index 88240bc..6660b21 100644 --- a/src/Tempest/Http/Router.php +++ b/src/Tempest/Http/Router.php @@ -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; + } } }