[CORE][Controller] Fix bug where a JSON request could not recieve a redirect response

This commit is contained in:
Hugo Sales 2022-03-04 15:14:05 +00:00
parent 94449c9153
commit 7a8d67f1e2
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -81,7 +81,6 @@ abstract class Controller extends AbstractController implements EventSubscriberI
*/
public function __invoke(Request $request)
{
$this->request = $request;
$class = static::class;
$method = 'on' . ucfirst(mb_strtolower($request->getMethod()));
$attributes = array_diff_key($request->attributes->get('_route_params'), array_flip(['_format', '_fragment', '_locale', 'template', 'accept', 'is_system_path']));
@ -156,10 +155,10 @@ abstract class Controller extends AbstractController implements EventSubscriberI
'vars' => $this->vars,
'response' => &$potential_response,
]) !== Event::stop) {
if ($format === 'json') {
$event->setResponse(new JsonResponse($response));
} elseif ($redirect !== false) {
if ($redirect !== false) {
$event->setResponse(new RedirectResponse($redirect));
} elseif ($format === 'json') {
$event->setResponse(new JsonResponse($response));
} elseif (!\is_null($template)) {
$event->setResponse($this->render($template, $this->vars));
} else {