Hi everyone,
What would be the correct way to change the application settings within a Middleware?
I’m passing the container in the constructor like so:
$app->add(new \App\Middleware\Language($app->getContainer()));
Somewhere inside the middleware im doing:
…
$this->ci->get(‘settings’)[‘locale’] = $routeInfo[2][‘lang’];
…
return $next($request, $response);
Then, im trying to initialize the Symfony Translator dependency using the setting I’ve just set in the middleware, but ‘locale’ has not changed his value previously:
$translator = new \Symfony\Component\Translation\Translator($c->get('settings')['locale'],
new \Symfony\Component\Translation\MessageSelector());