Moves AJAX handler response handling

Fixes octobercms/october#2208
This commit is contained in:
Luke Towers 2016-07-13 09:51:18 -06:00 committed by GitHub
parent c8f8c5cc27
commit b73811fefc
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.
*/
@ -457,6 +446,17 @@ class Controller extends Extendable
$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);
}
catch (ValidationException $ex) {