26
26
use Tobyz \JsonApiServer \Context ;
27
27
use Tobyz \JsonApiServer \Schema \HasMany ;
28
28
use Tobyz \JsonApiServer \Schema \HasOne ;
29
+ use Tobyz \JsonApiServer \Schema \Meta ;
29
30
use Tobyz \JsonApiServer \Serializer ;
30
31
use function Tobyz \JsonApiServer \evaluate ;
31
32
use function Tobyz \JsonApiServer \json_api_response ;
@@ -79,7 +80,11 @@ public function handle(Context $context): ResponseInterface
79
80
foreach ($ models as $ model ) {
80
81
$ serializer ->add ($ this ->resource , $ model , $ include );
81
82
}
82
-
83
+
84
+ $ meta = array_values (array_map (function (Meta $ meta ) use ($ context ) {
85
+ return new Structure \Meta ($ meta ->getName (), $ meta ->getValue ()($ context ));
86
+ }, $ context ->getMeta ()));
87
+
83
88
return json_api_response (
84
89
new Structure \CompoundDocument (
85
90
new Structure \PaginatedCollection (
@@ -90,7 +95,8 @@ public function handle(Context $context): ResponseInterface
90
95
new Structure \Link \SelfLink ($ this ->buildUrl ($ context ->getRequest ())),
91
96
new Structure \Meta ('offset ' , $ offset ),
92
97
new Structure \Meta ('limit ' , $ limit ),
93
- ...($ total !== null ? [new Structure \Meta ('total ' , $ total )] : [])
98
+ ...($ total !== null ? [new Structure \Meta ('total ' , $ total )] : []),
99
+ ...$ meta
94
100
)
95
101
);
96
102
}
0 commit comments