From 09add5fbff9d626bd4708123fe27d37ff610142b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 18 Nov 2018 20:13:38 +0100 Subject: [PATCH] Moved locale middleware to before the not found handler, so that it never gets executed otherwise --- config/autoload/middleware-pipeline.global.php | 4 +++- module/Core/src/Response/NotFoundHandler.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/autoload/middleware-pipeline.global.php b/config/autoload/middleware-pipeline.global.php index 4bd14e39..100fa714 100644 --- a/config/autoload/middleware-pipeline.global.php +++ b/config/autoload/middleware-pipeline.global.php @@ -13,7 +13,6 @@ return [ 'middleware' => [ ErrorHandler::class, Expressive\Helper\ContentLengthMiddleware::class, - Common\Middleware\LocaleMiddleware::class, ], 'priority' => 12, ], @@ -47,6 +46,9 @@ return [ 'post-routing' => [ 'middleware' => [ Expressive\Router\Middleware\DispatchMiddleware::class, + + // Only if a not found error is triggered, set-up the locale to be used + Common\Middleware\LocaleMiddleware::class, Core\Response\NotFoundHandler::class, ], 'priority' => 1, diff --git a/module/Core/src/Response/NotFoundHandler.php b/module/Core/src/Response/NotFoundHandler.php index 2350ce52..733e93de 100644 --- a/module/Core/src/Response/NotFoundHandler.php +++ b/module/Core/src/Response/NotFoundHandler.php @@ -55,6 +55,6 @@ class NotFoundHandler implements RequestHandlerInterface } $notFoundTemplate = $request->getAttribute(self::NOT_FOUND_TEMPLATE, $this->defaultTemplate); - return new Response\HtmlResponse($this->renderer->render($notFoundTemplate, ['request' => $request]), $status); + return new Response\HtmlResponse($this->renderer->render($notFoundTemplate), $status); } }