. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Contracts\UserInterface; 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 theme for the current session. */ class SelectTheme implements RequestHandlerInterface, StatusCodeInterface { /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $user = $request->getAttribute('user'); $theme = $request->getParsedBody()['theme']; Session::put('theme', $theme); $user->setPreference('theme', $theme); return response('', StatusCodeInterface::STATUS_NO_CONTENT); } }