[CORE][Controller][TESTS] Fix issue that arrises in tests where the Accept header is not specified

This commit is contained in:
Hugo Sales 2021-07-28 21:29:27 +00:00
parent d07cb79844
commit e6d20bd30d
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
1 changed files with 3 additions and 2 deletions

View File

@ -100,8 +100,9 @@ class Controller extends AbstractController implements EventSubscriberInterface
$template = $this->vars['_template'];
unset($this->vars['_template'], $this->vars['request']);
// Respond in the most preferred acceptable content type
$format = $request->getFormat($request->getAcceptableContentTypes()[0]);
// Respond in the the most preffered acceptable content type
$accept = $request->getAcceptableContentTypes() ?: ['text/html'];
$format = $request->getFormat($accept[0]);
switch ($format) {
case 'html':
$event->setResponse($this->render($template, $this->vars));