[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 untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

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