22
22
use Tobyz \JsonApiServer \Schema \Concerns \HasVisibility ;
23
23
24
24
use function Tobyz \JsonApiServer \has_value ;
25
- use function Tobyz \JsonApiServer \json_api_response ;
26
25
use function Tobyz \JsonApiServer \set_value ;
27
26
28
27
class Create implements Endpoint, OpenApiPathsProvider
@@ -83,14 +82,14 @@ public function handle(Context $context): ?ResponseInterface
83
82
84
83
if ($ asyncResult !== null ) {
85
84
if (is_string ($ asyncResult )) {
86
- $ response = json_api_response ($ this ->buildDocument ($ context ))->withHeader (
85
+ $ response = $ context -> createResponse ($ this ->buildDocument ($ context ))->withHeader (
87
86
'Location ' ,
88
87
$ context ->api ->basePath . '/ ' . ltrim ($ asyncResult , '/ ' ),
89
88
);
90
89
} else {
91
90
$ context = $ context ->forModel ([$ this ->asyncCollection ], $ asyncResult );
92
91
93
- $ response = json_api_response (
92
+ $ response = $ context -> createResponse (
94
93
$ this ->buildResourceDocument ($ asyncResult , $ context ),
95
94
)->withHeader (
96
95
'Content-Location ' ,
@@ -110,9 +109,9 @@ public function handle(Context $context): ?ResponseInterface
110
109
111
110
$ this ->saveFields ($ context , $ data , true );
112
111
113
- $ response = json_api_response (
114
- $ document = $ this ->buildResourceDocument ($ model , $ context ),
115
- ) ->withStatus (201 );
112
+ $ response = $ context
113
+ -> createResponse ( $ document = $ this ->buildResourceDocument ($ model , $ context ))
114
+ ->withStatus (201 );
116
115
117
116
if ($ location = $ document ['data ' ]['links ' ]['self ' ] ?? null ) {
118
117
$ response = $ response ->withHeader ('Location ' , $ location );
0 commit comments