From 7056acf06172f65784482d6de3705a659afc7eaf Mon Sep 17 00:00:00 2001 From: hooman naghiee Date: Tue, 23 Aug 2016 12:29:49 +0430 Subject: [PATCH] Fix when nullResource returned from Transformers This fix is needed in case of returning NullResource and return null. In case of meta is not empty we will return meta array --- src/Scope.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Scope.php b/src/Scope.php index 027f9290..0191e2dc 100644 --- a/src/Scope.php +++ b/src/Scope.php @@ -273,6 +273,14 @@ public function toArray() // Pull out all of OUR metadata and any custom meta data to merge with the main level data $meta = $serializer->meta($this->resource->getMeta()); + // in case of returning NullResource we should return null and not to go with array_merge + if (is_null($data)) { + if (!empty($meta)) { + return $meta; + } + return null; + } + return array_merge($data, $meta); }