@@ -42,6 +42,7 @@ final class ErrorListener extends SymfonyErrorListener
42
42
{
43
43
use ContentNegotiationTrait;
44
44
use OperationRequestInitiatorTrait;
45
+ private static mixed $ error ;
45
46
46
47
public function __construct (
47
48
object |array |string |null $ controller ,
@@ -112,10 +113,8 @@ protected function duplicateRequest(\Throwable $exception, Request $request): Re
112
113
}
113
114
114
115
if (!$ operation ->getProvider ()) {
115
- $ data = 'jsonapi ' === $ format && $ errorResource instanceof ConstraintViolationListAwareExceptionInterface ? $ errorResource ->getConstraintViolationList () : $ errorResource ;
116
- $ dup ->attributes ->set ('_api_error_resource ' , $ data );
117
- $ operation = $ operation ->withExtraProperties (['_api_error_resource ' => $ data ])
118
- ->withProvider ([self ::class, 'provide ' ]);
116
+ static ::$ error = 'jsonapi ' === $ format && $ errorResource instanceof ConstraintViolationListAwareExceptionInterface ? $ errorResource ->getConstraintViolationList () : $ errorResource ;
117
+ $ operation = $ operation ->withProvider ([self ::class, 'provide ' ]);
119
118
}
120
119
121
120
// For our swagger Ui errors
@@ -221,13 +220,9 @@ private function getFormatOperation(?string $format): string
221
220
};
222
221
}
223
222
224
- public static function provide (Operation $ operation , array $ uriVariables = [], array $ context = [])
223
+ public static function provide (): mixed
225
224
{
226
- if ($ data = ($ context ['request ' ] ?? null )?->attributes->get ('_api_error_resource ' )) {
227
- return $ data ;
228
- }
229
-
230
- if ($ data = $ operation ->getExtraProperties ()['_api_error_resource ' ] ?? null ) {
225
+ if ($ data = static ::$ error ) {
231
226
return $ data ;
232
227
}
233
228
0 commit comments