Skip to content

Commit

Permalink
Merge pull request #59 from OskarD/master
Browse files Browse the repository at this point in the history
Fixed relationship data array format to follow JSON API v1.0 standard
  • Loading branch information
nilportugues committed May 11, 2016
2 parents 6fe49a1 + 37f923f commit ea24d0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Helpers/DataLinksHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public static function setResponseDataRelationship(array &$mappings, array &$arr
}

$newData[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName] = array_filter($newData[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName]);
if (!empty($newData[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName])) {
$data[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyNameKey][] = $newData[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName];
if (!empty($newData[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName][JsonApiTransformer::DATA_KEY])) {
$data[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyNameKey][JsonApiTransformer::DATA_KEY][] = $newData[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName][JsonApiTransformer::DATA_KEY];
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions tests/JsonApiTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public function testItWillSerializeToJsonApiAComplexObject()
"id":"1"
}
},
"comments":[
{
"data":{
"type":"comment",
"id":"1000"
}
}
]
"comments": {
"data": [
{
"type": "comment",
"id": "1000"
}
]
}
}
},
"included":[
Expand Down

0 comments on commit ea24d0f

Please sign in to comment.