@@ -141,38 +141,10 @@ private function resolveIdentifierValue($identifierValue, string $parameterName)
141
141
return $ identifierValue ;
142
142
}
143
143
144
- // TODO: php 8 remove method_exists
145
- if (method_exists ($ identifierValue , '__toString ' ) || $ identifierValue instanceof \Stringable) {
144
+ if ($ identifierValue instanceof \Stringable) {
146
145
return (string ) $ identifierValue ;
147
146
}
148
147
149
- // TODO: remove this in 3.0
150
- // we could recurse to find correct identifiers until there it is a scalar but this is not really supported and adds a lot of complexity
151
- // instead we're deprecating this behavior in favor of something that can be transformed to a string
152
- if ($ this ->isResourceClass ($ relatedResourceClass = $ this ->getObjectClass ($ identifierValue ))) {
153
- trigger_deprecation ('api-platform/core ' , '2.7 ' , 'Using a resource class as identifier is deprecated, please make this identifier Stringable ' );
154
- $ relatedOperation = $ this ->resourceMetadataFactory ->create ($ relatedResourceClass )->getOperation ();
155
-
156
- $ relatedLinks = [];
157
- if ($ relatedOperation instanceof GraphQlOperation) {
158
- $ relatedLinks = $ relatedOperation ->getLinks ();
159
- } elseif ($ relatedOperation instanceof HttpOperation) {
160
- $ relatedLinks = $ relatedOperation ->getUriVariables ();
161
- }
162
-
163
- if (1 === \count ($ relatedLinks )) {
164
- $ identifierValue = $ this ->getIdentifierValue ($ identifierValue , $ relatedResourceClass , current ($ relatedLinks )->getIdentifiers ()[0 ], $ parameterName );
165
-
166
- if (\is_scalar ($ identifierValue )) {
167
- return $ identifierValue ;
168
- }
169
-
170
- if ($ identifierValue instanceof \Stringable || method_exists ($ identifierValue , '__toString ' )) {
171
- return (string ) $ identifierValue ;
172
- }
173
- }
174
- }
175
-
176
148
throw new RuntimeException (sprintf ('We were not able to resolve the identifier matching parameter "%s". ' , $ parameterName ));
177
149
}
178
150
}
0 commit comments