From 2f455cc6541bebba9dad9f23d5f04442a9580fa5 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Thu, 19 Dec 2013 10:41:02 +0200 Subject: [PATCH] add json encode for controller --- application/Espo/Core/ControllerManager.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application/Espo/Core/ControllerManager.php b/application/Espo/Core/ControllerManager.php index 5b325dbdc8..19a9389e6b 100644 --- a/application/Espo/Core/ControllerManager.php +++ b/application/Espo/Core/ControllerManager.php @@ -70,16 +70,19 @@ class ControllerManager if (!method_exists($controller, $actionMethodName)) { throw new NotFound("Action '$actionMethodName' does not exist in controller '$controller'"); } - + $result = $controller->$actionMethodName($params, $data); $afterMethodName = 'after' . $actionNameUcfirst; if (method_exists($controller, $afterMethodName)) { $controller->$afterMethodName($params, $data); } - - return $result; + + if (is_array($result) || is_bool($result)) { + return \Espo\Core\Utils\Json::encode($result); + } + return $result; } }