Skip to content

Commit

Permalink
Merge pull request #90 from basz/fix/metadata-on-collection
Browse files Browse the repository at this point in the history
Fix/metadata on collection
  • Loading branch information
nilportugues authored May 3, 2017
2 parents 4cb7645 + 258f547 commit e7ab074
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/JsonApiTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ protected function serializedArray(array $value)
$data = array_filter($data);

$this->setResponseLinks($value, $data);
$this->setResponseMeta($data);
$this->setResponseVersion($data);

return (empty($data['data'])) ? array_merge(['data' => []], $data) : $data;
Expand Down
16 changes: 16 additions & 0 deletions tests/Behaviour/JsonApiTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,15 @@ public function testItWillSerializeToJsonApiAnArrayOfObjects()
$mapper->setClassMap([$postMapping->getClassName() => $postMapping]);

$jsonApiJsonApiSerializer = new JsonApiTransformer($mapper);
$jsonApiJsonApiSerializer->setMeta(
[
'author' => [
'name' => 'Nil Portugués Calderó',
'email' => '[email protected]',
],
]
);
$jsonApiJsonApiSerializer->addMeta('is_devel', true);

$expected = <<<JSON
{
Expand Down Expand Up @@ -916,6 +925,13 @@ public function testItWillSerializeToJsonApiAnArrayOfObjects()
}
}
],
"meta":{
"author":{
"name":"Nil Portugués Calderó",
"email":"[email protected]"
},
"is_devel":true
},
"jsonapi":{
"version":"1.0"
}
Expand Down

0 comments on commit e7ab074

Please sign in to comment.