. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; 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 assert; use function is_string; use function response; /** * Select a new theme for the current session. */ class SelectTheme implements RequestHandlerInterface { /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $user = $request->getAttribute('user'); assert($user instanceof UserInterface); $theme = $request->getAttribute('theme'); assert(is_string($theme)); Session::put('theme', $theme); $user->setPreference(UserInterface::PREF_THEME, $theme); return response(); } }