From e048a1457fb155db69130e1d5c48442e4e52fad5 Mon Sep 17 00:00:00 2001 From: Noel da Costa Date: Mon, 8 Mar 2021 11:19:09 +0000 Subject: [PATCH 1/2] Update JsonApiListener.php Support deletion of relationships as per https://jsonapi.org/format/#crud-updating-to-one-relationships --- src/Listener/JsonApiListener.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Listener/JsonApiListener.php b/src/Listener/JsonApiListener.php index e24d9b25..bbfaebb0 100644 --- a/src/Listener/JsonApiListener.php +++ b/src/Listener/JsonApiListener.php @@ -1341,6 +1341,9 @@ protected function _convertJsonApiDocumentArray(array $document): array { $result = []; + // support deletion of relationships as per https://jsonapi.org/format/#crud-updating-to-one-relationships + if($document['data'] === null) return $result; + // convert primary resource if (array_key_exists('id', $document['data'])) { $result['id'] = $document['data']['id']; From e900e92aae534c43aa126fa97050302fbc5a6f52 Mon Sep 17 00:00:00 2001 From: Noel da Costa Date: Mon, 8 Mar 2021 11:21:40 +0000 Subject: [PATCH 2/2] Update JsonApiListener.php Syntax fixes for sniffer --- src/Listener/JsonApiListener.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Listener/JsonApiListener.php b/src/Listener/JsonApiListener.php index bbfaebb0..b7fe5a23 100644 --- a/src/Listener/JsonApiListener.php +++ b/src/Listener/JsonApiListener.php @@ -1342,7 +1342,9 @@ protected function _convertJsonApiDocumentArray(array $document): array $result = []; // support deletion of relationships as per https://jsonapi.org/format/#crud-updating-to-one-relationships - if($document['data'] === null) return $result; + if($document['data'] === null) { + return $result; + } // convert primary resource if (array_key_exists('id', $document['data'])) {