Processes a MethodNotAllowed exception that occured on a JSON request.
Symfony\Component\HttpKernel\Exception\FlattenException $exception: The flattened exception.
Symfony\Component\HttpFoundation\Request $request: The request object that triggered this exception.
public function on405Json(FlattenException $exception, Request $request) {
$response = new JsonResponse();
$response
->setStatusCode(405, 'Method Not Allowed');
return $response;
}