diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index 6117f1a1f..747e2e8d4 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -426,11 +426,12 @@ class Controller extends Extendable } /* - * If the handler returned a redirect, process it so framework.js knows to redirect - * the browser and not the request! + * If the handler returned a redirect, process the URL and dispose of it so + * framework.js knows to redirect the browser and not the request! */ if ($result instanceof RedirectResponse) { $responseContents['X_OCTOBER_REDIRECT'] = $result->getTargetUrl(); + $result = null; } /* * No redirect is used, look for any flash messages @@ -448,14 +449,18 @@ class Controller extends Extendable /* * If the handler returned an array, we should add it to output for rendering. - * If it is a string, add it to the array with the key "result". + * If it is a scalar, add it to the array with the key "result". + * Otherwise, pass it to Laravel as a response object. */ if (is_array($result)) { $responseContents = array_merge($responseContents, $result); } - elseif (is_string($result)) { + elseif (is_scalar($result)) { $responseContents['result'] = $result; } + elseif ($result !== null) { + return $result; + } return Response::make()->setContent($responseContents); } diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php index e19040474..c10595084 100644 --- a/modules/cms/classes/Controller.php +++ b/modules/cms/classes/Controller.php @@ -638,23 +638,28 @@ class Controller } /* - * If the handler returned a redirect, process it so framework.js knows to redirect - * the browser and not the request! + * If the handler returned a redirect, process the URL and dispose of it so + * framework.js knows to redirect the browser and not the request! */ if ($result instanceof RedirectResponse) { $responseContents['X_OCTOBER_REDIRECT'] = $result->getTargetUrl(); + $result = null; } /* * If the handler returned an array, we should add it to output for rendering. - * If it is a string, add it to the array with the key "result". + * If it is a scalar, add it to the array with the key "result". + * Otherwise, pass it to Laravel as a response object. */ if (is_array($result)) { $responseContents = array_merge($responseContents, $result); } - elseif (is_string($result)) { + elseif (is_scalar($result)) { $responseContents['result'] = $result; } + elseif ($result !== null) { + return $result; + } return Response::make($responseContents, $this->statusCode); }