From c069c76a30e8125e0ef01cee50d180200eb18606 Mon Sep 17 00:00:00 2001 From: Frank Dekker Date: Thu, 4 May 2023 16:37:42 +0200 Subject: [PATCH] Use getContentTypeFormat instead of getContentType method --- src/Constraint/RequestConstraintValidator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Constraint/RequestConstraintValidator.php b/src/Constraint/RequestConstraintValidator.php index 27dca93..df234ba 100644 --- a/src/Constraint/RequestConstraintValidator.php +++ b/src/Constraint/RequestConstraintValidator.php @@ -68,7 +68,10 @@ private function validateRequest(RequestConstraint $constraint, Request $request return; } - if (in_array($request->getContentType(), ['json', 'jsonld'], true)) { + // `getContentType` deprecated since symfony 6.2 + $contentType = method_exists($request, 'getContentTypeFormat') ? $request->getContentTypeFormat() : $request->getContentType(); + + if (in_array($contentType, ['json', 'jsonld'], true)) { $data = $this->validateAndGetJsonBody($constraint, $request); if ($data === null) { return;