Skip to content

Commit

Permalink
Merge pull request #34 from 123inkt/Resolve-symfony-request-getConten…
Browse files Browse the repository at this point in the history
…tType-deprecation

Use getContentTypeFormat instead of getContentType method
  • Loading branch information
frankdekker committed May 4, 2023
2 parents 08fae63 + c069c76 commit d8b8ba1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Constraint/RequestConstraintValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d8b8ba1

Please sign in to comment.