Skip to content

Commit e7ab074

Browse files
authored
Merge pull request nilportugues#90 from basz/fix/metadata-on-collection
Fix/metadata on collection
2 parents 4cb7645 + 258f547 commit e7ab074

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/JsonApiTransformer.php

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ protected function serializedArray(array $value)
234234
$data = array_filter($data);
235235

236236
$this->setResponseLinks($value, $data);
237+
$this->setResponseMeta($data);
237238
$this->setResponseVersion($data);
238239

239240
return (empty($data['data'])) ? array_merge(['data' => []], $data) : $data;

tests/Behaviour/JsonApiTransformerTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,15 @@ public function testItWillSerializeToJsonApiAnArrayOfObjects()
885885
$mapper->setClassMap([$postMapping->getClassName() => $postMapping]);
886886

887887
$jsonApiJsonApiSerializer = new JsonApiTransformer($mapper);
888+
$jsonApiJsonApiSerializer->setMeta(
889+
[
890+
'author' => [
891+
'name' => 'Nil Portugués Calderó',
892+
'email' => '[email protected]',
893+
],
894+
]
895+
);
896+
$jsonApiJsonApiSerializer->addMeta('is_devel', true);
888897

889898
$expected = <<<JSON
890899
{
@@ -916,6 +925,13 @@ public function testItWillSerializeToJsonApiAnArrayOfObjects()
916925
}
917926
}
918927
],
928+
"meta":{
929+
"author":{
930+
"name":"Nil Portugués Calderó",
931+
932+
},
933+
"is_devel":true
934+
},
919935
"jsonapi":{
920936
"version":"1.0"
921937
}

0 commit comments

Comments
 (0)