@@ -105,7 +105,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
105
105
&& ($ isAlternateResourceMetadata || $ canonicalUriTemplate )
106
106
) {
107
107
$ canonicalOperation = $ operation ;
108
- if ($ this ->operationMetadataFactory && null !== ( $ canonicalUriTemplate) ) {
108
+ if ($ this ->operationMetadataFactory && null !== $ canonicalUriTemplate ) {
109
109
$ canonicalOperation = $ this ->operationMetadataFactory ->create ($ canonicalUriTemplate , $ context );
110
110
}
111
111
@@ -119,6 +119,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
119
119
120
120
$ status ??= self ::METHOD_TO_CODE [$ method ] ?? 200 ;
121
121
122
+ $ requestParts = parse_url ($ request ->getRequestUri ());
122
123
if ($ this ->iriConverter && !isset ($ headers ['Content-Location ' ])) {
123
124
try {
124
125
if ($ hasData ) {
@@ -127,10 +128,16 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
127
128
$ iri = $ this ->iriConverter ->getIriFromResource ($ operation ->getClass (), UrlGeneratorInterface::ABS_PATH , $ operation );
128
129
}
129
130
130
- $ headers ['Content-Location ' ] = sprintf ('%s.%s ' , $ iri , $ request ->getRequestFormat ());
131
+ if ($ iri ) {
132
+ $ location = \sprintf ('%s.%s ' , $ iri , $ request ->getRequestFormat ());
133
+ if (isset ($ requestParts ['query ' ])) {
134
+ $ location .= '? ' .$ requestParts ['query ' ];
135
+ }
131
136
132
- if ((201 === $ status || (300 <= $ status && $ status < 400 )) && 'POST ' === $ method && !isset ($ headers ['Location ' ])) {
133
- $ headers ['Location ' ] = $ iri ;
137
+ $ headers ['Content-Location ' ] = $ location ;
138
+ if ((201 === $ status || (300 <= $ status && $ status < 400 )) && 'POST ' === $ method && !isset ($ headers ['Location ' ])) {
139
+ $ headers ['Location ' ] = $ iri ;
140
+ }
134
141
}
135
142
} catch (InvalidArgumentException |ItemNotFoundException |RuntimeException ) {
136
143
}
0 commit comments