From 02ce42b08be91acd05cd28daa3f05fa1913fe464 Mon Sep 17 00:00:00 2001 From: Markus Fischer Date: Wed, 7 Oct 2015 14:16:48 +0200 Subject: [PATCH] Pave path to technically allow PATCH requests --- src/EchoIt/JsonApi/Handler.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/EchoIt/JsonApi/Handler.php b/src/EchoIt/JsonApi/Handler.php index d42d952..750b7c2 100644 --- a/src/EchoIt/JsonApi/Handler.php +++ b/src/EchoIt/JsonApi/Handler.php @@ -277,7 +277,7 @@ public static function successfulHttpStatusCode($method, $model = null) // if we did a put request, we need to ensure that the model wasn't // changed in other ways than those specified by the request // Ref: http://jsonapi.org/format/#crud-updating-responses-200 - if ($method === 'PUT' && $model instanceof Model) { + if (($method === 'PATCH' || $method === 'PUT') && $model instanceof Model) { // check if the model has been changed if ($model->isChanged()) { // return our response as if there was a GET request @@ -288,6 +288,7 @@ public static function successfulHttpStatusCode($method, $model = null) switch ($method) { case 'POST': return BaseResponse::HTTP_CREATED; + case 'PATCH': case 'PUT': case 'DELETE': return BaseResponse::HTTP_NO_CONTENT; @@ -296,7 +297,7 @@ public static function successfulHttpStatusCode($method, $model = null) } // Code shouldn't reach this point, but if it does we assume that the - // client has made a bad request, e.g. PATCH + // client has made a bad request. return BaseResponse::HTTP_BAD_REQUEST; }