. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Session; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function response; /** * Select a new language for the current session. */ class SelectLanguage implements RequestHandlerInterface, StatusCodeInterface { /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $user = $request->getAttribute('user'); $language = $request->getAttribute('language'); Session::put('language', $language); $user->setPreference('language', $language); return response('', StatusCodeInterface::STATUS_NO_CONTENT); } }