Merge pull request #2209 from LukeTowers/develop

Moves AJAX handler response handling
This commit is contained in:
Samuel Georges 2016-07-16 13:07:54 +10:00 committed by GitHub
commit 09adbbe069
1 changed files with 11 additions and 11 deletions

View File

@ -418,17 +418,6 @@ class Controller extends Extendable
throw new ApplicationException(Lang::get('cms::lang.ajax_handler.not_found', ['name'=>$handler]));
}
/*
* 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 (is_array($result)) {
$responseContents = array_merge($responseContents, $result);
}
elseif (is_string($result)) {
$responseContents['result'] = $result;
}
/*
* Render partials and return the response as array that will be converted to JSON automatically.
*/
@ -456,6 +445,17 @@ class Controller extends Extendable
if ($this->hasAssetsDefined()) {
$responseContents['X_OCTOBER_ASSETS'] = $this->getAssetPaths();
}
/*
* 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 (is_array($result)) {
$responseContents = array_merge($responseContents, $result);
}
elseif (is_string($result)) {
$responseContents['result'] = $result;
}
return Response::make()->setContent($responseContents);
}