[ROUTER][UTIL] Allow specifying the Accept format for a route

This commit is contained in:
2021-08-18 21:33:07 +01:00
parent 86bdc398c5
commit 26bf78360b
2 changed files with 4 additions and 3 deletions

View File

@@ -118,10 +118,11 @@ class Controller extends AbstractController implements EventSubscriberInterface
$event->setResponse($this->render($template, $this->vars));
break;
case 'json':
case 'jsonld':
$event->setResponse(new JsonResponse($response));
break;
default:
throw new ClientException(_m('Unsupported format'), 406); // 406 Not Acceptable
throw new ClientException(_m('Unsupported format: {format}', ['format' => $format]), 406); // 406 Not Acceptable
}
return $event;