From a68da979520d3b8ca493bdd6a1e3729d8996dea8 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 24 Nov 2015 19:02:40 +0100 Subject: [PATCH] default locale --- app/bootstrap.php.d/30-trans.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/bootstrap.php.d/30-trans.php b/app/bootstrap.php.d/30-trans.php index 92cf0c3..f4334aa 100644 --- a/app/bootstrap.php.d/30-trans.php +++ b/app/bootstrap.php.d/30-trans.php @@ -63,9 +63,13 @@ $app->get('/', function (Request $request) use ($app) { )); }); -$app->after(function(Request $request, Response $response) use ($app) { - $value = $request->cookies->get('locale'); +$app->after(function (Request $request, Response $response) use ($app) { + if ($response instanceof RedirectResponse) { + return; + } + + $value = $request->get('_locale'); $cookie = new Cookie('locale', $value, strtotime('+1 month')); - $response->headers->setCookie($cookie); + $response->headers->setCookie($cookie); });