From 8570c0ebbe079a516f12baf497e1298f7a541286 Mon Sep 17 00:00:00 2001 From: Will Morgan Date: Wed, 31 Jul 2013 16:22:26 +0100 Subject: [PATCH] Fixing validationresult --- code/RestfulServer.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/RestfulServer.php b/code/RestfulServer.php index 800fe5d..f70ad27 100644 --- a/code/RestfulServer.php +++ b/code/RestfulServer.php @@ -570,14 +570,22 @@ protected function postHandler($className, $id, $actionName) { else { $formatterClass = $className; } - $responseFormatter = $this->getResponseDataFormatter($formatterClass); + if($result instanceof DataObject) { + $responseFormatter = $this->getResponseDataFormatter($formatterClass); + } + else { + $responseFormatter = $reqFormatter; + } + $this->getResponse()->addHeader('Content-Type', $responseFormatter->getOutputContentType()); // Handle validation errors if($result instanceof ValidationResult) { return $this->handleValidationError($result, $reqFormatter); } - else if($result instanceof ArrayList) { + + + if($result instanceof ArrayList) { return $reqFormatter->convertArrayList($result); } else if(is_array($result)) {